/* ==========================================================================
   02-layout.css — Mobile-First App Shell, Sidebar, Topbar & Bottom Nav
   ========================================================================== */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.app-root {
  min-height: 100vh;
  display: block;
}

.sidebar {
  display: none;
}

.workspace {
  min-height: 100vh;
  min-width: 0;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

/* Calm Sticky Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-emblem {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-en);
  font-weight: 750;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}
.brand-emblem span {
  opacity: 0.82;
  margin-left: 1px;
}

.topbar h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sublink {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.main-canvas {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 12px 24px;
}

.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  width: 100%;
}

/* Mobile Bottom Tab Bar */
.mobile-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-around;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}

.mobile-tabbar button {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.mobile-tabbar button svg {
  width: 19px;
  height: 19px;
}
.mobile-tabbar button.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

/* Desktop Sidebar Layout (>= 980px) */
@media (min-width: 980px) {
  .app-root {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-light);
    padding: 20px 14px;
    gap: 16px;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 2px 6px 16px;
    border-bottom: 1px solid var(--border-light);
  }
  .sidebar-brand strong {
    display: block;
    font-size: 16.5px;
    font-weight: 750;
    color: var(--text-primary);
  }
  .sidebar-brand span {
    font-size: 11.5px;
    color: var(--text-muted);
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13.5px;
    text-align: right;
    transition: background 0.15s, color 0.15s;
  }
  .sidebar-nav button svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }
  .sidebar-nav button:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
  }
  .sidebar-nav button.active {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent);
    font-weight: 700;
  }

  .sidebar-foot {
    margin-top: auto;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .status-line {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-weight: 600;
  }
  .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok-badge);
  }
  .dev-credit {
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    line-height: 1.5;
  }
  .dev-credit a {
    display: block;
    font-weight: 700;
    color: var(--accent);
  }

  .workspace {
    padding-bottom: 0;
  }
  .mobile-tabbar {
    display: none;
  }
  .topbar {
    padding: 13px 28px;
  }
  .topbar .brand-emblem {
    display: none;
  }
  .topbar h1 {
    font-size: 18.5px;
  }
  .main-canvas {
    padding: 24px 28px 36px;
  }
}
