/* ── WRETAN v2.0 — Layout ────────────────────────────────────────────────── */

/* ── App Shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* nav-root dissolves from layout tree so .sidebar is a direct flex child of body */
#nav-root { display: contents; }

/* ── Sidebar Overlay (desktop: hidden, mobile: for bottom-sheet) ─────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: overlayIn 0.15s var(--ease);
}
.sidebar-overlay.visible { display: block; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100dvh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-x: hidden;   /* allow width:0 collapse to clip content */
  overflow-y: visible;  /* don't clip the scrollable nav-body */
  transition: width 0.28s var(--ease), min-width 0.28s var(--ease);
  position: relative;
  z-index: 10;
  border-right: 1px solid var(--border);
}

/* Desktop collapsed state */
body.sb-collapsed .sidebar {
  width: 0;
  min-width: 0;
}

body.sb-collapsed .icon-sidebar-open {
  display: none;
}

body.sb-collapsed .icon-sidebar-close {
  display: block;
}

/* Sidebar header */
.sidebar-header {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
}
.brand-link:hover .wordmark em { filter: brightness(1.2); }
.brand-link:hover .brand-icon { filter: brightness(1.2); }

.brand-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--accent);
}

.wordmark {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 550;
  letter-spacing: 0.07em;
  color: var(--accent);
  white-space: nowrap;
}
.wordmark em { color: var(--accent); font-style: normal; }

.version-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.6rem;
  background: var(--bg2);
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* ─────────────────────────────────────────────
   NAV BODY
───────────────────────────────────────────── */
.nav-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px 10px;
}

/* ─────────────────────────────────────────────
   GROUP WRAPPER
───────────────────────────────────────────── */
.nav-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1px;
}

/* HEADER ROW */
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 6px 6px;
}

/* ─────────────────────────────────────────────
   GROUP LABEL
───────────────────────────────────────────── */
.nav-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

/* ─────────────────────────────────────────────
   GROUP RULE
───────────────────────────────────────────── */
.nav-group-rule {
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.6;
  transform: scaleX(0.92);
  transform-origin: left;
  transition:
    transform 0.25s ease,
    opacity 0.25s ease,
    background 0.25s ease;
}

/* ─────────────────────────────────────────────
   NAV LINKS
───────────────────────────────────────────── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text2);
  text-decoration: none;
  position: relative;
  transition:
    background 0.18s ease,
    transform 0.15s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

/* left active bar */
.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  height: 64%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 0.15s ease, transform 0.18s ease;
}

/* hover state */
.nav-link:hover {
  background: var(--accent-bg);
  transform: translateX(2px);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.08);
}

/* active state */
.nav-link.active {
  background: var(--accent-bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18) inset;
  transform: translateX(2px);
}

/* active indicator */
.nav-link.active::before {
  opacity: 1;
  transform: scaleY(1);
}

/* keyboard focus */
.nav-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
  background: var(--accent-bg);
}

/* press feedback */
.nav-link:active {
  transform: translateX(1px) scale(0.99);
}

/* ─────────────────────────────────────────────
   ICONS
───────────────────────────────────────────── */
.nav-link .icon {
  width: 18px;
  height: 18px;

  color: var(--accent);
  opacity: 0.85;

  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    color 0.15s ease;
}

/* hover icon */
.nav-link:hover .icon {
  transform: scale(1.1);
}

/* ── Main Area ────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 20px;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.topbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  opacity: 0.8;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.topbar-toggle:hover {
  filter: brightness(1.2);
}
.topbar-toggle svg { display: block; }

.topbar-toggle .icon-sidebar-close {
  display: none;
}

body.sb-collapsed .topbar-toggle .icon-sidebar-open {
  display: none;
}

body.sb-collapsed .topbar-toggle .icon-sidebar-close {
  display: block;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--accent);
  font-family: var(--sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-home {
  display: flex;
  align-items: center;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
  transition: color 0.12s;
  border-radius: 3px;
  padding: 2px;
}
.breadcrumb-home:hover { filter: brightness(1.2); }
.breadcrumb-sep { color: var(--accent); flex-shrink: 0; }
.breadcrumb-page { color: var(--accent); overflow: hidden; text-overflow: ellipsis; }
.page-breadcrumb span { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

#live-clock {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* ── Content Area ─────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  animation: contentFadeIn 0.18s var(--ease);
}
@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Dashboard / Landing ─────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: 48px 0 40px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.hero-bg::before {
  display: none;
}

.hero-bg::after {
  display: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-bd);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 20px;
  animation: badgePop 0.4s var(--ease-out) 0.1s both;
}
.hero-badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes badgePop {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.hero-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  animation: heroSlide 0.5s var(--ease-out) 0.15s both;
}
.hero-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-bd);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.hero-logo-icon svg { width: 32px; height: 32px; }
.hero-title {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text);
  line-height: 1;
}
.hero-title em { color: var(--accent); font-style: normal; }
.hero-tagline {
  font-size: 0.82rem;
  color: var(--text3);
  margin-top: 2px;
  letter-spacing: 0.02em;
}
@keyframes heroSlide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-desc {
  font-size: 0.9rem;
  color: var(--text2);
  max-width: 520px;
  line-height: 1.65;
  margin-bottom: 28px;
  animation: heroSlide 0.5s var(--ease-out) 0.22s both;
}

.hero-stats {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  width: fit-content;
  box-shadow: var(--shadow);
  animation: heroSlide 0.5s var(--ease-out) 0.3s both;
}
.hero-stat {
  padding: 12px 24px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.hero-stat:last-child { border-right: none; }
.hero-stat-val {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.2;
}
.hero-stat-key {
  font-size: 0.62rem;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Homepage sections */
.home-section { margin-bottom: 36px; }
.section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.section-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.section-rule {
  flex: 1;
  height: 1px;
  background: var(--accent);
}

/* Tool cards grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 8px;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(var(--accent-rgb,37,99,235),0.04) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.15s;
}
.tool-card:hover {
  border-color: var(--accent-bd);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb,37,99,235),0.1);
  transform: translateY(-1px);
}
.tool-card:hover::before { opacity: 1; }

.tool-card-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-bd);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
  color: var(--accent);
}
.tool-card:hover .tool-card-icon {
  background: var(--accent-bg);
  border-color: var(--accent-bd);
}

.tool-card-body { min-width: 0; }
.tool-card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s;
}
.tool-card:hover .tool-card-name { color: var(--accent); }
.tool-card-desc {
  font-size: 0.68rem;
  color: var(--text3);
  line-height: 1.5;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 2;
}

/* About/Feature cards */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.feature-card {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.feature-card-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-bd);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--accent);
}
.feature-card-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.feature-card-desc {
  font-size: 0.72rem;
  color: var(--text3);
  line-height: 1.55;
}

/* ── Bottom Nav (mobile only) ────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  height: var(--bottomnav-h);
  padding: 0 75px;
}

/* Left button — justify to start */
.bottom-nav-inner > .bottom-nav-btn:first-child {
  justify-self: start;
}

/* Right button/link — justify to end */
.bottom-nav-inner > :last-child {
  justify-self: end;
}
.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(var(--accent-rgb), 0.5);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-btn:hover,
.bottom-nav-btn.active { color: var(--accent); }
.bottom-nav-btn svg { display: block; }

.bottom-nav-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-logo-ring {
  width: 38px;
  height: 38px;
  background: var(--accent-bg);
  border: 1.5px solid var(--accent-bd);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, box-shadow 0.15s;
  color: var(--accent);
}
.bottom-nav-logo:active .bottom-nav-logo-ring {
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb,37,99,235),0.15);
}
.bottom-nav-logo img { width: 22px; height: 22px; }
.bottom-nav-logo-label {
  font-size: 0.6rem;
  color: var(--text3);
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

/* ── Bottom Sheet ────────────────────────────────────────────────────────── */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--border);
  z-index: 300;
  transform: translateY(100%);
  transition: transform 0.3s var(--ease-out);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-sheet.open { transform: translateY(0); }

.bs-handle-wrap {
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}
.bs-handle {
  width: 36px;
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
}

.bs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 10px;
  flex-shrink: 0;
}
.bs-title {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}
.bs-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
  display: flex;
}

.bs-body {
  overflow-y: auto;
  padding: 10px 10px 10px;
  flex: 1;
}

.bs-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1px;
}

/* HEADER ROW */
.bs-group-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 6px 6px;
}

.bs-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.bs-group-rule {
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.6;
  transform: scaleX(0.92);
  transform-origin: left;
  transition:
    transform 0.25s ease,
    opacity 0.25s ease,
    background 0.25s ease;
}

.bs-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text2);
  text-decoration: none;
  position: relative;
  transition:
    background 0.18s ease,
    transform 0.15s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

/* left active bar */
.bs-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  height: 64%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 0.15s ease, transform 0.18s ease;
}

/* active state */
.bs-link.active {
  background: var(--accent-bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18) inset;
  transform: translateX(2px);
}

/* active indicator */
.bs-link.active::before {
  opacity: 1;
  transform: scaleY(1);
}

/* keyboard focus */
.bs-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
  background: var(--accent-bg);
}

/* press feedback */
.bs-link:active {
  transform: translateX(1px) scale(0.99);
}

.bs-link .icon {
  width: 18px;
  height: 18px;

  color: var(--accent);
  opacity: 0.85;

  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    color 0.15s ease;
}

/* ── View header ─────────────────────────────────────────────────────────── */
.view-header { margin-bottom: 20px; }
.view-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.view-sub {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 4px;
}

/* ── Layout utilities ─────────────────────────────────────────────────────── */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.cols-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
.stack  { display: flex; flex-direction: column; gap: 16px; }
