:root {
  --z: 1; --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bg: #070b14; --surface: rgba(16, 22, 38, 0.78); --solid: #111829;
  --surf2: rgba(255, 255, 255, 0.055); --line: rgba(255, 255, 255, 0.10); --rim: rgba(255, 255, 255, 0.20);
  --txt: #f3f6ff; --sub: #9aa7c7; --brand: #5b8def; --brand2: #8ab4ff; --ok: #10b981;
  --sh: 0 8px 28px rgba(0, 0, 0, 0.32); --r: 1rem; --pill: 999px;
}
:root[data-atmo="paper"] {
  --bg: #f5f1e9; --surface: rgba(255, 252, 247, 0.88); --solid: #fffdf9;
  --surf2: rgba(24, 21, 18, 0.05); --line: rgba(24, 21, 18, 0.10); --rim: rgba(24, 21, 18, 0.18);
  --txt: #1b1815; --sub: #665e55; --brand: #c85a32; --brand2: #e07a52; --sh: 0 8px 24px rgba(24, 21, 18, 0.08);
}
:root[data-atmo="rain"] { --brand: #10b981; --brand2: #34d399; --surface: rgba(12, 24, 20, 0.80); --solid: #0f1f1a; }
:root[data-atmo="sunset"] { --brand: #f97316; --brand2: #fb923c; --surface: rgba(26, 17, 36, 0.80); --solid: #1b1126; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-size: calc(16px * var(--z)); max-width: 100vw; }
body {
  display: flex; overflow: hidden; background: var(--bg); color: var(--txt);
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  line-height: 1.5; -webkit-font-smoothing: antialiased; word-break: keep-all;
}
.num { font-variant-numeric: tabular-nums; }
svg { width: 1.12em; height: 1.12em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#bgCanvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* Left Opera Workspace Rail */
#wsRail {
  position: relative; z-index: 20; width: 4.1rem; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; padding: 2.8rem 0.4rem 0.75rem;
  background: var(--surface); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--line); gap: 0.6rem;
}
.ws-logo { margin-bottom: 0.25rem; }
.orb { display: block; width: 0.75rem; height: 0.75rem; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--ok)); box-shadow: 0 0 12px var(--brand); }
.ws-list { flex: 1; display: flex; flex-direction: column; gap: 0.45rem; width: 100%; }
.ws-btn {
  position: relative; width: 100%; padding: 0.5rem 0.2rem; border-radius: 0.85rem; border: 1px solid transparent;
  background: transparent; color: var(--sub); display: flex; flex-direction: column; align-items: center; gap: 0.16rem;
  transition: all .18s var(--ease);
}
.ws-btn:hover { background: var(--surf2); color: var(--txt); }
.ws-btn.on { background: var(--surf2); border-color: var(--wc); color: var(--txt); box-shadow: 0 0 14px rgba(0,0,0,0.2); }
.ws-btn.on::before { content: ''; position: absolute; left: -0.4rem; top: 22%; bottom: 22%; width: 3px; border-radius: 4px; background: var(--wc); }
.ws-lbl { font-size: 0.68rem; font-weight: 700; }
.ws-foot { display: flex; flex-direction: column; gap: 0.35rem; width: 100%; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.rail-btn {
  position: relative; width: 100%; height: 2.2rem; border-radius: 0.7rem; border: 0; background: transparent;
  color: var(--sub); display: flex; align-items: center; justify-content: center;
}
.rail-btn:hover { background: var(--surf2); color: var(--txt); }
.sound-ind { position: absolute; top: 5px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.sound-ind.on { background: var(--ok); }

/* Main Shell + Top Tab Islands */
#shell { position: relative; z-index: 10; flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
#topChrome {
  background: var(--surface); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.tab-strip {
  display: flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.7rem;
  min-height: 2.85rem; overflow-x: auto; scrollbar-width: none; -webkit-app-region: drag;
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab-strip button, .tab-strip .island { -webkit-app-region: no-drag; flex-shrink: 0; }

.t-home {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 2rem; padding: 0 0.75rem;
  border-radius: var(--pill); border: 1px solid var(--line); background: var(--surf2); font-size: 0.8rem; font-weight: 700;
}
.t-home.on { background: var(--brand); color: #fff; border-color: transparent; }

.pinned-strip { display: flex; align-items: center; gap: 0.28rem; }
.pin-tab {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 2rem; padding: 0 0.55rem 0 0.3rem;
  border-radius: 0.65rem; border: 1px solid transparent; background: var(--surf2); font-size: 0.78rem; font-weight: 600; color: var(--sub);
}
.pin-tab:hover { color: var(--txt); border-color: var(--rim); }
.pin-tab.on { background: var(--solid); color: var(--txt); border-color: var(--brand); }
.pt-ico { width: 1.35rem; height: 1.35rem; border-radius: 0.42rem; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.76rem; }
.strip-sep { width: 1px; height: 1.2rem; background: var(--line); flex-shrink: 0; }

/* Opera Tab Islands */
.islands-strip { display: flex; align-items: center; gap: 0.4rem; }
.island {
  display: inline-flex; align-items: center; gap: 0.22rem; padding: 0.18rem 0.3rem;
  border-radius: 0.75rem; border: 1.5px solid var(--isl, var(--brand)); background: rgba(255,255,255,0.03);
}
.isl-tag {
  background: var(--isl, var(--brand)); color: #fff; border: 0; border-radius: 0.5rem;
  padding: 0.18rem 0.5rem; font-size: 0.72rem; font-weight: 800;
}
.isl-tag em { font-style: normal; opacity: 0.85; margin-left: 0.2rem; }
.t-pill { display: inline-flex; align-items: center; border-radius: 0.5rem; background: transparent; max-width: 145px; }
.t-pill.on { background: var(--solid); }
.t-sel { border: 0; background: none; padding: 0.2rem 0.45rem; font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.t-x { border: 0; background: none; padding: 0 0.3rem; color: var(--sub); font-size: 0.85rem; }
.t-x:hover { color: var(--txt); }
.t-add { width: 1.9rem; height: 1.9rem; border-radius: 0.55rem; border: 1px dashed var(--line); background: transparent; color: var(--sub); font-size: 1rem; }
.t-add:hover { color: var(--txt); border-color: var(--rim); }

.strip-right { margin-left: auto; display: flex; align-items: center; gap: 0.3rem; padding-left: 0.5rem; }
.top-chip {
  height: 1.9rem; padding: 0 0.65rem; border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--surf2); font-size: 0.76rem; font-weight: 700; color: var(--sub);
}
.top-chip:hover { color: var(--txt); border-color: var(--rim); }
.top-chip.ai { background: linear-gradient(135deg, var(--brand), var(--ok)); color: #fff; border-color: transparent; }

/* Slim Nav Bar */
.nav-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.38rem 0.7rem; border-top: 1px solid var(--line); }
.nav-row[hidden] { display: none; }
.nav-btns { display: flex; gap: 0.2rem; }
.nav-btn { width: 1.85rem; height: 1.85rem; border-radius: 0.5rem; border: 0; background: transparent; color: var(--sub); font-weight: 700; }
.nav-btn:hover, .nav-btn.on { background: var(--surf2); color: var(--brand2); }
.nav-form { flex: 1; min-width: 0; }
.nav-inp { width: 100%; height: 1.95rem; padding: 0 0.85rem; border-radius: var(--pill); border: 1px solid var(--line); background: var(--surf2); font-size: 0.84rem; }
.nav-inp:focus { outline: none; border-color: var(--brand); background: var(--solid); }

/* Stage: Calm Compass Home OR Clean 1-Screen / 2-Split WebStage */
#stageArea { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.home-view { height: 100%; overflow-y: auto; overflow-x: hidden; padding: 1.6rem 2rem 2.5rem; }
.home-view[hidden] { display: none; }
.h-inner { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }
.h-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.h-tag { font-size: 0.8rem; font-weight: 700; color: var(--brand2); }
.h-title { margin: 0.2rem 0 0; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.5px; }
.h-clock { font-size: 2.8rem; font-weight: 200; letter-spacing: -2px; line-height: 1; }

.h-search {
  display: flex; align-items: center; gap: 0.45rem; padding: 0.42rem 0.5rem 0.42rem 1rem;
  border-radius: var(--pill); background: var(--surface); border: 1px solid var(--rim); box-shadow: var(--sh);
}
.h-search input { flex: 1; border: 0; background: transparent; font-size: 0.96rem; outline: none; min-width: 0; }
.h-engs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: -0.65rem; }
.eng-p {
  padding: 0.28rem 0.78rem; border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--surf2); color: var(--sub); font-size: 0.78rem; font-weight: 700;
}
.eng-p.on { background: var(--brand); color: #fff; border-color: transparent; }

.compass-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 1rem; }
.c-card {
  background: var(--surface); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; box-shadow: var(--sh);
  display: flex; flex-direction: column; gap: 0.65rem;
}
.c-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }
.c-sub { font-size: 0.76rem; color: var(--sub); }
.one-inp {
  width: 100%; padding: 0.58rem 0.8rem; border-radius: 0.7rem; border: 1px solid var(--brand);
  background: var(--surf2); font-weight: 700; font-size: 0.92rem;
}
.top3-list { display: flex; flex-direction: column; gap: 0.42rem; }
.t3-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.55rem; border-radius: 0.6rem; background: var(--surf2); }
.t3-row input[type=checkbox] { accent-color: var(--ok); width: 1rem; height: 1rem; }
.t3-row input[type=text] { flex: 1; border: 0; background: transparent; font-size: 0.88rem; outline: none; }
.t3-row.done input[type=text] { text-decoration: line-through; color: var(--sub); }

.rec-list { display: flex; flex-direction: column; gap: 0.42rem; }
.rec-btn {
  display: flex; justify-content: space-between; align-items: center; padding: 0.58rem 0.85rem;
  border-radius: 0.72rem; border: 1px solid var(--line); background: var(--surf2); font-weight: 700; font-size: 0.88rem;
}
.rec-btn:hover { border-color: var(--brand); color: var(--brand2); }
.q-note { width: 100%; border-radius: 0.68rem; border: 1px dashed var(--line); background: var(--surf2); padding: 0.55rem 0.75rem; font-size: 0.84rem; resize: none; }

.ws-section { display: flex; flex-direction: column; gap: 0.75rem; }
.ws-sec-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.ws-sec-head strong { font-size: 1rem; margin-right: 0.5rem; }
.ws-sec-head span { font-size: 0.82rem; color: var(--sub); }
.app-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 0.7rem; }
.a-tile {
  display: flex; align-items: center; gap: 0.35rem; padding: 0.65rem 0.75rem; border-radius: 0.95rem;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh); transition: transform .16s var(--ease);
}
.a-tile:hover { transform: translateY(-2px); border-color: var(--rim); }
.a-main { display: flex; align-items: center; gap: 0.65rem; flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 0; }
.a-ico { width: 2.3rem; height: 2.3rem; border-radius: 0.72rem; color: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.a-txt { min-width: 0; display: flex; flex-direction: column; }
.a-txt strong { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-txt span { font-size: 0.75rem; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-pin { border: 0; background: transparent; opacity: 0.35; font-size: 0.85rem; padding: 0.25rem; }
.a-pin.on, .a-pin:hover { opacity: 1; }

/* Web Stage (1-Screen or 2-Column Split) */
.web-stage { height: 100%; width: 100%; display: flex; background: #fff; }
.web-stage[hidden] { display: none; }
.tab-webview { flex: 1; height: 100%; border: 0; }
.tab-webview[hidden] { display: none !important; }
.web-stage.is-split .tab-webview.is-right { border-left: 2px solid var(--line); }

/* Drawers & Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.46rem 0.95rem; border-radius: var(--pill); border: 1px solid var(--line); background: var(--surf2); font-size: 0.84rem; font-weight: 700; }
.btn.pri { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-color: transparent; }
.btn.sm { padding: 0.25rem 0.65rem; font-size: 0.76rem; }
.btn.lg { padding: 0.8rem 1.8rem; font-size: 0.96rem; }
.icon-sm { width: 1.7rem; height: 1.7rem; border: 0; border-radius: 0.45rem; background: transparent; color: var(--sub); }

.side-drawer {
  position: fixed; top: 3.1rem; right: 0.7rem; bottom: 0.7rem; width: min(420px, calc(100vw - 1.4rem)); z-index: 600;
  background: var(--solid); border: 1px solid var(--rim); border-radius: 1.15rem; box-shadow: var(--sh);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(115%); opacity: 0; pointer-events: none; transition: all .24s var(--ease);
}
.side-drawer.open { transform: translateX(0); opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 0.9rem; }
.d-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.d-card { padding: 0.85rem; border-radius: 0.85rem; background: var(--surf2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.5rem; }
.d-row { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.d-inp, .d-inp-t, .d-area { width: 100%; padding: 0.45rem 0.65rem; border-radius: 0.55rem; border: 1px solid var(--line); background: var(--solid); font-size: 0.85rem; }
.d-inp-t { flex: 1; font-weight: 700; }
.f-clk { font-size: 3.6rem; font-weight: 200; letter-spacing: -2px; }
.ai-tabs { display: flex; gap: 0.28rem; flex-wrap: wrap; }
.ai-t { padding: 0.25rem 0.6rem; border-radius: var(--pill); border: 1px solid var(--line); background: var(--surf2); color: var(--sub); font-size: 0.75rem; font-weight: 700; }
.ai-t.on { background: var(--brand); color: #fff; border-color: transparent; }
.ai-webview { flex: 1; width: 100%; border: 0; background: #fff; }

.break-overlay { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; background: rgba(6, 9, 19, 0.92); backdrop-filter: blur(28px); }
.break-overlay[hidden] { display: none; }
.break-card { text-align: center; padding: 2rem; }
.badge { display: inline-block; padding: 0.28rem 0.85rem; border-radius: var(--pill); background: var(--surf2); color: var(--brand2); font-size: 0.78rem; font-weight: 700; }
.break-clock { font-size: 4.8rem; font-weight: 200; letter-spacing: -3px; margin: 0.3rem 0 0.7rem; }

#toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); z-index: 999;
  background: var(--solid); border: 1px solid var(--rim); padding: 0.55rem 1.1rem; border-radius: var(--pill);
  box-shadow: var(--sh); display: flex; align-items: center; gap: 0.65rem; font-size: 0.85rem; font-weight: 600;
}
#toast[hidden] { display: none; }
.toast-undo { background: var(--brand); color: #fff; border: 0; border-radius: var(--pill); padding: 0.2rem 0.65rem; font-size: 0.76rem; font-weight: 700; }

/* Responsive iPhone / Mobile */
@media (max-width: 780px) {
  body { flex-direction: column-reverse; width: 100vw; }
  #shell { height: auto; flex: 1; min-height: 0; }
  #wsRail { flex-shrink: 0; }
  #shell, #stageArea, .home-view, .h-inner, .compass-grid, .c-card { min-width: 0; max-width: 100%; }
  .h-inner { width: 100%; }
  .h-top { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
  .h-title { font-size: 1.2rem; }
  .h-clock { display: none; }
  .tab-strip { padding: 0.4rem 0.5rem; }
  .t-home span { display: none; }
  .app-cards { grid-template-columns: 1fr; }
  .side-drawer { top: 0.5rem; bottom: 4.1rem; right: 0.5rem; width: calc(100vw - 1rem); }
  #wsRail { width: 100%; height: 3.6rem; flex-direction: row; padding: 0.35rem 0.6rem; border-right: 0; border-top: 1px solid var(--line); }
  .ws-logo, .ws-foot { display: none; }
  .ws-list { flex-direction: row; justify-content: space-around; }
  .ws-btn.on::before { display: none; }
  .pinned-strip, .strip-sep, #btnNewTab, #btnBreak, #btnDualGo { display: none; }
  .home-view { padding: 1rem 0.95rem 1.8rem; }
  .h-clock { font-size: 2rem; }
  .compass-grid { grid-template-columns: 1fr; }
}
