/* layout.css — shell, components, responsive, device frame */

.root-wrap { height: 100%; }
.root-wrap[data-framed="true"] {
  display: grid; place-items: center;
  background: var(--bg-sunken);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
  padding: 28px; overflow: auto;
}

/* ---- device frame ---- */
.device-frame {
  background: oklch(28% 0.02 262);
  border-radius: 40px;
  padding: 12px;
  box-shadow: var(--shadow-lg), 0 0 0 1px oklch(20% 0.02 262);
  flex-shrink: 0;
}
.device-frame[data-kind="tablet"] { border-radius: 30px; padding: 14px; }
.device-screen {
  width: 100%; height: 78vh; max-height: 880px;
  position: relative;
  background: var(--bg); border-radius: 30px; overflow: hidden;
}
.device-frame[data-kind="tablet"] .device-screen { border-radius: 18px; height: 80vh; }

/* ---- app shell ---- */
.app-shell {
  display: grid; height: 100%;
  grid-template-columns: 264px 1fr;
  background: var(--bg);
}
.app-shell.mode-tablet { grid-template-columns: 76px 1fr; }
.app-shell.mode-phone { grid-template-columns: 1fr; }
.root-wrap[data-framed="false"] .app-shell { height: 100vh; }

/* ---- sidebar ---- */
.sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}
.sidebar[data-compact="true"] { align-items: stretch; }
.sidebar[data-compact="true"] .nav-item { justify-content: center; padding: 11px; }

.nav-item:hover[data-active="false"] { background: var(--bg-sunken); }

/* ---- main ---- */
.main { overflow-y: auto; height: 100%; }
.main-inner {
  max-width: 920px; margin: 0 auto;
  padding: 30px 34px;
}
.mode-tablet .main-inner { padding: 26px 26px; }
.mode-phone .main-inner { padding: 20px 18px; }

/* ---- searchbar ---- */
.searchbar {
  display: flex; align-items: center; gap: 9px;
  height: 42px; padding: 0 14px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line-2);
  width: 240px; transition: border-color .14s ease, box-shadow .14s ease;
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbar input { border: none; outline: none; background: none; font-size: 14px; color: var(--ink); width: 100%; }
.searchbar input::placeholder { color: var(--ink-4); }

/* ---- buttons ---- */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 99px; border: none;
  background: var(--accent); color: white; font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-soft); transition: filter .14s ease, transform .1s ease;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { cursor: not-allowed; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 13px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font-size: 13px; font-weight: 600; transition: all .14s ease;
}
.ghost-btn:hover { border-color: var(--ink-4); color: var(--ink); }

.link-btn { border: none; background: none; color: var(--accent-ink); font-size: 12.5px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  transition: all .14s ease; flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--ink-4); color: var(--ink); }
.icon-btn.lg { width: 42px; height: 42px; }

.hero-cta { transition: filter .14s ease, transform .1s ease; }
.hero-cta:hover { filter: brightness(0.92); }

/* ---- card hovers ---- */
.res-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.res-row:hover { background: var(--bg-sunken); }

/* ---- card grid ---- */
.card-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
}
.mode-phone .card-grid { grid-template-columns: 1fr; }

/* ---- timeline rail ---- */
.tl-row { display: grid; grid-template-columns: 56px 1fr; gap: 18px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; position: relative; }
.tl-rail::before {
  content: ""; position: absolute; top: 0; bottom: -8px; left: 50%;
  width: 2px; transform: translateX(-50%); background: var(--line);
}
.tl-row:last-child .tl-rail::before { display: none; }
.tl-node {
  width: 48px; height: 48px; border-radius: 14px; border: 1.5px solid;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; z-index: 1; box-shadow: var(--shadow-sm); margin-top: 2px; gap: 1px;
}
.tl-content { padding-bottom: 26px; min-width: 0; }
.mode-phone .tl-row { grid-template-columns: 44px 1fr; gap: 12px; }
.mode-phone .tl-node { width: 40px; height: 40px; border-radius: 12px; }

/* ---- settings bottom sheet (phone, contained in frame) ---- */
.settings-overlay {
  position: absolute; z-index: 60;
  align-items: flex-end; justify-content: center;
}
.root-wrap[data-framed="false"] .settings-overlay { position: fixed; }
.settings-sheet {
  width: 100%; background: var(--surface);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.22);
  animation: sheetUp .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grip {
  width: 36px; height: 4px; border-radius: 99px;
  background: var(--line-2); margin: 0 auto 14px;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
}
.ui-toggle {
  position: relative; width: 46px; height: 28px; flex-shrink: 0;
  border: none; border-radius: 99px; padding: 0; cursor: pointer;
  background: var(--line-2); transition: background .18s ease;
}
.ui-toggle[data-on="true"] { background: var(--accent); }
.ui-toggle i {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s cubic-bezier(.2,.8,.2,1);
}
.ui-toggle[data-on="true"] i { transform: translateX(18px); }

/* ---- overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: oklch(20% 0.02 262 / 0.42);
  backdrop-filter: blur(3px);
  display: flex; justify-content: flex-end;
  animation: fadeIn .2s ease;
}
.overlay.center { align-items: center; justify-content: center; padding: 24px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slideover {
  width: 460px; max-width: 100%; height: 100%;
  background: var(--surface); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideIn .28s cubic-bezier(.2,.8,.2,1);
}
.modal {
  width: 540px; max-width: 100%; max-height: 88vh;
  background: var(--surface); border-radius: var(--r-xl);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg); animation: scaleIn .24s cubic-bezier(.2,.8,.2,1);
}

/* ---- bottom nav (phone) ---- */
.bottomnav {
  position: absolute; bottom: 0; left: 0; right: 0; height: 68px;
  background: var(--nav-bg); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 8px; z-index: 40;
}
.root-wrap[data-framed="false"] .bottomnav { position: fixed; }

/* ---- phone floating action bar (above bottom nav) ---- */
.phone-actions {
  position: absolute; right: 16px; bottom: 80px; z-index: 41;
  display: flex; align-items: center; gap: 10px;
}
.root-wrap[data-framed="false"] .phone-actions { position: fixed; }
.phone-actions .icon-btn {
  background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.phone-actions .primary-btn { box-shadow: 0 6px 16px var(--accent-soft); }
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: none; background: none; color: var(--ink-4); font-size: 10.5px; font-weight: 600;
  padding: 6px 10px; transition: color .14s ease;
}
.bn-item[data-active="true"] { color: var(--ink); }
.bn-add {
  width: 50px; height: 50px; border-radius: 50%; border: none;
  background: var(--accent); color: white; display: grid; place-items: center;
  box-shadow: 0 6px 16px var(--accent-soft); margin-top: -14px;
}

/* ---- scan animation ---- */
@keyframes scan {
  0% { left: -40%; } 100% { left: 100%; }
}

/* tablet/desktop full-height when not framed */
/* 100dvh = dynamic viewport height (excludes Safari browser chrome on iOS) */
.root-wrap[data-framed="false"] { height: 100vh; height: 100dvh; }
