@font-face { font-family: "GmarketSans"; src: url("/fonts/GmarketSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "GmarketSans"; src: url("/fonts/GmarketSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --sunk: #efeee9;
  --line: #e4e2dc;
  --text: #1b1c1f;
  --muted: #64656b;
  --faint: #6f7076;
  --work: #167a4c;
  --think: #3f5fc8;
  --ask: #b35a00;
  --idle: #a3a4a9;
  --off: #c9c9cc;
  --bar: #1b1c1f;
  --shadow: 0 1px 2px rgb(20 20 25 / 5%), 0 6px 20px -8px rgb(20 20 25 / 10%);
  --sheet: 0 -8px 40px -12px rgb(20 20 25 / 25%);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --sans: "GmarketSans", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1a1b1e;
    --sunk: #222327;
    --line: #2a2b30;
    --text: #ececee;
    --muted: #a0a1a7;
    --faint: #8f9097;
    --work: #3ccf8a;
    --think: #8aa2ff;
    --ask: #ffa34d;
    --idle: #6d6e74;
    --off: #45464b;
    --bar: #ececee;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --sheet: 0 -8px 40px -12px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 500 15px/1.5 var(--sans); letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
::selection { background: color-mix(in srgb, var(--think) 28%, transparent); }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--think); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, p, ol { margin: 0; }

.brand { font-weight: 700; font-size: 17px; letter-spacing: 0.04em; }

/* ---------- gate ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login, .setup { width: min(320px, 100%); display: grid; gap: 10px; }
.gate-sub { color: var(--muted); margin: -4px 0 14px; }
.login input {
  height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; font-size: 16px; caret-color: var(--think);
  transition: border-color .2s, box-shadow .2s;
}
.login input:focus { border-color: var(--think); box-shadow: 0 0 0 4px color-mix(in srgb, var(--think) 18%, transparent); }
.login input::placeholder { color: var(--faint); }
.pin { -webkit-text-security: disc; text-security: disc; }
.login button {
  height: 48px; margin-top: 4px; border: 0; border-radius: 12px; background: var(--text); color: var(--bg);
  font-weight: 700; transition: transform .15s var(--ease), opacity .2s;
}
.login button:active { transform: scale(.98); }
.login button:disabled { opacity: .5; }
.err { min-height: 1.5em; color: var(--ask); font-size: 14px; }
.setup-msg { font-size: 20px; font-weight: 700; margin-top: 8px; }

/* ---------- top ---------- */
.top { padding: max(16px, env(safe-area-inset-top)) 16px 4px; max-width: 1180px; margin: 0 auto; }
.top-row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.conn { font-size: 13px; color: var(--ask); }
.ghost { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 0 6px; min-height: 44px; min-width: 44px; font-size: 14px; border-radius: 10px; }
@media (hover: hover) { .ghost:hover { color: var(--text); } button.stat:hover { background: var(--sunk); } }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 640px; gap: 1px; margin-top: 10px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stat {
  display: grid; gap: 2px; align-content: start; text-align: left; padding: 10px 12px;
  background: var(--surface); border: 0; min-width: 0;
}
.stat-n { font-weight: 700; font-size: 20px; line-height: 1.2; }
.stat-n small { font-size: 13px; margin-left: 1px; color: var(--muted); }
.stat-l { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-pc .stat-l + .stat-l { margin-top: -3px; }
.stat-l b { font-weight: 500; color: var(--text); }
#st-ask.on .stat-n { color: var(--ask); }

/* ---------- cards ---------- */
.grid {
  max-width: 1180px; margin: 0 auto; padding: 14px 16px max(28px, env(safe-area-inset-bottom));
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
@media (max-width: 380px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.card {
  background: var(--surface); border-radius: 18px; padding: 16px; box-shadow: var(--shadow);
  display: grid; gap: 10px; align-content: start; cursor: pointer; outline-offset: 3px;
  transition: transform .25s var(--ease), box-shadow .25s, opacity .4s;
  animation: rise .5s var(--ease) both;
}
.card:active { transform: scale(.985); }
.card.s-off .avatar, .card.s-off .req { opacity: .55; }
.card:focus-visible { border-radius: 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.card-head { display: flex; gap: 12px; align-items: center; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sunk); font-weight: 700; font-size: 15px; position: relative;
}
.avatar::after { /* state ring */
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--c, transparent); transition: border-color .4s;
}
.who { min-width: 0; }
.name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; transition: background-color .4s; }
.word { color: var(--c); font-weight: 700; transition: color .4s; }
.dur { color: var(--faint); }
.s-work { --c: var(--work); } .s-think { --c: var(--think); } .s-ask { --c: var(--ask); } .s-idle { --c: var(--idle); } .s-off { --c: var(--off); }
.s-work .dot, .s-work .avatar::after { animation: pulse 1.6s ease-in-out infinite; }
.s-think .dot, .s-think .avatar::after { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.s-off .word { color: var(--faint); }
.s-idle .avatar::after, .s-off .avatar::after { border-style: dashed; }

.req { font-size: 15px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.req:empty { display: none; }
.now { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now:empty { display: none; }
.card.s-ask .now { color: var(--ask); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.prog { display: grid; gap: 6px; }
.prog-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.prog-n { color: var(--text); font-weight: 700; }
.bar { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--bar); transition: width .8s var(--ease); }

.acts { list-style: none; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.acts:empty { display: none; }
.act { display: flex; gap: 8px; font-size: 13px; align-items: baseline; min-width: 0; animation: fade .4s var(--ease) both; }
.act-l { flex: 0 1 auto; min-width: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-t { flex: 1 1 0; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-time { flex: none; color: var(--faint); font-size: 12px; }
@keyframes fade { from { opacity: 0; } }

.empty { text-align: center; color: var(--muted); padding: 60px 16px; }

/* ---------- panel: bottom sheet on phones, side panel on wide screens ---------- */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 28%); opacity: 0; transition: opacity .35s var(--ease); z-index: 10; }
.scrim.on { opacity: 1; }
.panel {
  position: fixed; z-index: 11; left: 0; right: 0; bottom: 0; height: 92dvh; overscroll-behavior: contain; touch-action: pan-y;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--sheet);
  display: flex; flex-direction: column; transform: translateY(105%); visibility: hidden;
  transition: transform .3s var(--ease), visibility 0s .3s; outline: none;
}
.panel.on { transform: none; visibility: visible; transition: transform .38s var(--ease), visibility 0s; }
.panel.drag { transition: none; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; box-shadow: 0 0 0 14px transparent; }
.panel-head { touch-action: none; }
@media (min-width: 900px) {
  .panel-head { touch-action: auto; }
  .panel { left: auto; top: 0; width: 440px; height: auto; border-radius: 0; transform: translateX(105%); box-shadow: -12px 0 40px -16px rgb(0 0 0 / 25%); }
  .grab { display: none; }
}
.panel-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 20px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 19px; font-weight: 700; }
.panel-head .ghost { margin-left: auto; }
.panel-body { flex: 1; overflow-y: auto; padding: 6px 20px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sec { padding: 16px 0 4px; }
.sec h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 0 0 8px; }
.sec .txt { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.sec .meta { font-size: 12px; color: var(--faint); margin-top: 4px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 18px 1fr auto; gap: 4px 8px; font-size: 14px; align-items: baseline; }
.mark { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--idle); align-self: center; }
.item.done .mark { background: var(--work); border-color: var(--work); }
.item.running .mark { border-color: var(--work); animation: pulse 1.6s ease-in-out infinite; }
.item.failed .mark { background: var(--ask); border-color: var(--ask); }
.item.done .it { color: var(--muted); }
.item .sub { grid-column: 2 / 4; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tm { font-size: 12px; color: var(--faint); }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { border-bottom: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 0; font-size: 14px; width: 100%; text-align: left; background: none; border: 0; }
button.row { min-height: 44px; }
.tl li:last-child { border-bottom: 0; }
.tl .tm { color: var(--faint); font-size: 12px; padding-top: 2px; }
.tl .tt { color: var(--muted); display: block; font-size: 13px; overflow-wrap: anywhere; }
.chat-soon { padding: 12px 20px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-box { height: 44px; border-radius: 22px; background: var(--sunk); color: var(--muted); display: flex; align-items: center; padding: 0 16px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}
