/* SDOS v2 shell: rail + topbar + content + drawer */
@layer shell {
  .shell { display: flex; min-height: 100vh; }

  /* ---- icon rail ---- */
  .rail {
    width: 62px; flex: 0 0 62px;
    background: var(--rail);
    display: flex; flex-direction: column; align-items: center;
    padding: 14px 0; gap: 6px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .rail::-webkit-scrollbar { width: 0; }
  .rail-logo {
    width: 34px; height: 34px; border-radius: 9px;
    background: #ffffff; color: var(--rail);
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
    margin-bottom: 14px; text-decoration: none;
  }
  .rail-group { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .rail-group-label {
    font-size: 8.5px; font-weight: 700; letter-spacing: 0.13em;
    color: oklch(0.6 0.03 250); text-transform: uppercase; margin: 8px 0 1px;
  }
  .rail-spacer { flex: 1; min-height: 6px; }
  .rail a.rail-item {
    width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center;
    color: #9db8cd; text-decoration: none;
  }
  .rail a.rail-item:hover { background: rgba(255, 255, 255, 0.08); color: #cfe0ee; }
  .rail a.rail-item[aria-current="page"] { background: rgba(255, 255, 255, 0.16); color: #fff; }
  .rail-avatar {
    width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center; text-decoration: none; margin-top: 2px;
  }
  .rail-avatar[aria-current="page"] { background: rgba(255, 255, 255, 0.16); }
  .avatar-tile {
    width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-size: 11px; font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.35);
  }

  /* ---- main column ---- */
  .maincol { flex: 1; min-width: 0; display: flex; flex-direction: column; }

  .topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 24px 12px;
    background: var(--bg);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar-titles { min-width: 0; }
  .topbar-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
  .topbar-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
  .topbar-spacer { flex: 1; }
  .topbar-search { flex-shrink: 0; }
  .topbar-search input {
    width: 280px; max-width: 36vw; border-radius: 10px; padding: 9px 13px;
    font-size: 13.5px; background: var(--surface); border: 1px solid var(--line-strong);
  }
  .topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .theme-toggle {
    flex-shrink: 0; border: 1px solid var(--line-strong); cursor: pointer;
    background: var(--surface); color: var(--text-2); border-radius: 9px;
    width: 36px; height: 36px; font-size: 15px; line-height: 1;
    display: grid; place-items: center;
  }
  .theme-toggle:hover { background: var(--surface-2); }
  .seg { display: flex; background: var(--surface-3); border-radius: 9px; padding: 2px; flex-shrink: 0; }
  .seg-form { display: contents; }
  .seg-btn {
    border: none; cursor: pointer; border-radius: 7px; padding: 6px 12px;
    font-size: 12.5px; font-weight: 600; background: transparent; color: var(--muted);
    text-decoration: none; display: inline-flex; align-items: center; line-height: 1.4;
  }
  .seg-btn:hover { text-decoration: none; }
  .seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 35, 60, 0.15); }

  .content { padding: 18px 22px 40px; flex: 1; min-width: 0; }

  /* ---- detail drawer ---- */
  .drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(430px, 100vw);
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
    transform: translateX(102%);
    transition: transform 0.18s ease;
    z-index: 60; overflow-y: auto;
  }
  .drawer.open { transform: none; }
  .drawer-overlay {
    position: fixed; inset: 0; background: rgba(10, 18, 28, 0.35);
    opacity: 0; pointer-events: none; transition: opacity 0.18s ease; z-index: 55;
  }
  .drawer.open + .drawer-overlay, .drawer-overlay.open { opacity: 1; pointer-events: auto; }
  .drawer-inner { padding: 18px; }
  .drawer-close {
    position: sticky; top: 8px; float: right;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 50%; width: 30px; height: 30px; font-size: 14px;
  }

  @media (max-width: 700px) {
    .rail { display: none; }
    .topbar { flex-wrap: wrap; }
    .topbar-search { flex: 1 1 100%; order: 9; max-width: none; margin-left: 0; }
    .content { padding: 14px 14px 40px; }
  }
}
