:root {
  --bg: #f4f5f8; --surface: #fff; --surface-2: #f8f9fb; --col: #eceef3; --border: #dfe2e9;
  --text: #1c1f26; --text-2: #5b6170; --text-3: #8a90a0;
  --accent: #4f46e5; --accent-soft: #eef0ff; --accent-text: #fff;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e2;
  --danger: #c2410c; --danger-soft: #fdece4; --run: #2563eb; --run-soft: #e8f0fe; --wait-soft: #eff0f3;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --surface: #1a1d24; --surface-2: #20242d; --col: #171a20; --border: #2c313c;
    --text: #e8eaef; --text-2: #a3a9b7; --text-3: #737a8a;
    --accent: #818cf8; --accent-soft: #262a4a; --accent-text: #0f1020;
    --ok: #4ade80; --ok-soft: #16301f; --warn: #fbbf24; --warn-soft: #3a2d12;
    --danger: #fb923c; --danger-soft: #3b2216; --run: #60a5fa; --run-soft: #172a45; --wait-soft: #262a32;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: var(--text); }
[hidden] { display: none !important; }
#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.bar {
  flex: none; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo, .logo-big { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); flex: none;
  background-image: linear-gradient(90deg, transparent 22%, rgba(255,255,255,.95) 22% 37%, transparent 37% 44%, rgba(255,255,255,.75) 44% 59%, transparent 59% 66%, rgba(255,255,255,.55) 66% 81%, transparent 81%);
  background-size: 100% 60%; background-repeat: no-repeat; background-position: center 45%; }
.logo-big { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 8px; }
.pcs { font-size: 13px; color: var(--text-2); }
.icon-btn { border: 0; background: none; font-size: 24px; line-height: 1; padding: 4px 8px; cursor: pointer; color: var(--text); text-decoration: none; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; min-height: 42px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.big { width: 100%; padding: 12px; font-size: 16px; }
.btn.link { border: 0; background: none; color: var(--accent); font-weight: 500; }

.center { overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 16px; flex: 1; }
.center h1 { margin: 4px 0; font-size: 22px; }
.sub { color: var(--text-2); font-size: 13.5px; margin: 6px 0 14px; }
.err { color: var(--danger); font-size: 13.5px; }
.form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.form input, .form select, .form textarea { padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 16px; font-weight: 400; color: var(--text); }
.form textarea { resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pad { padding: 16px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; }
.tab { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.cnt { margin-left: 6px; font-size: 12px; opacity: .8; }

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 100px; display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--text-3); padding: 40px 0; }
.card { text-align: left; width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; cursor: pointer; }
.card.st-review { border-left: 4px solid var(--warn); }
.card.st-running { border-left: 4px solid var(--run); }
.card.st-done { opacity: .75; }
.row { display: flex; align-items: center; gap: 8px; }
.row.meta { flex-wrap: wrap; gap: 5px; }
.title { font-weight: 700; font-size: 15.5px; flex: 1; min-width: 0; }
.prio { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.p-high { background: #e11d48; } .p-medium { background: #f59e0b; } .p-low { background: #9ca3af; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--wait-soft); color: var(--text-2); }
.pill.dev.off { opacity: .55; }
.st-review .pill.st, .pill.st.st-review { background: var(--warn-soft); color: var(--warn); }
.st-running .pill.st, .pill.st.st-running { background: var(--run-soft); color: var(--run); }
.st-done .pill.st, .pill.st.st-done { background: var(--ok-soft); color: var(--ok); }
.time { margin-left: auto; font-size: 12px; color: var(--text-3); }
.hint { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hint.q { color: var(--warn); }
.hint.s b { color: var(--accent); }
.prog { height: 5px; border-radius: 99px; background: var(--col); overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--accent); }
.fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-text); font-size: 30px; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer; }

.detail { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 130px; }
.detail.pad { padding-bottom: 40px; }
.info { background: var(--surface); padding: 12px 16px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.stages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.stg { font-size: 10.5px; text-align: center; padding: 5px 1px; border-radius: 6px; background: var(--col); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stg.past { background: var(--accent-soft); color: var(--accent); }
.stg.cur { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.stg.sug { outline: 2px dashed var(--accent); outline-offset: -2px; color: var(--accent); }
.activity { margin: 0; color: var(--run); font-size: 13.5px; display: flex; gap: 6px; align-items: center; }
.ask { border-radius: 12px; padding: 12px; font-size: 14.5px; }
.ask.s { background: var(--warn-soft); border: 1px solid var(--warn); }
.ask.s b { color: var(--warn); }
.ask.q { background: var(--warn-soft); border: 1px solid var(--warn); }
.ask .btns { display: flex; gap: 8px; margin-top: 10px; }
.ask .btns .btn { flex: 1; }
.ask .sub { margin: 6px 0 0; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.acts .btn { flex: 1; min-width: 96px; }

.log { padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.msg time { display: block; font-size: 11px; opacity: .65; margin-top: 3px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; white-space: normal; }
.msg.sys { align-self: stretch; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; }
.msg.err { align-self: stretch; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.msg.meta { align-self: center; font-size: 12px; color: var(--text-3); padding: 0; }
.msg.files { align-self: stretch; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; white-space: normal; }
.tools { font-size: 12.5px; color: var(--text-2); font-family: var(--mono); padding: 0 4px; }
.tools summary { cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atts { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.file { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 9px 10px; cursor: pointer; }
.file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.file small { color: var(--text-3); }
.msg.me .file { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.4); color: inherit; }
.msg.me .file small { color: inherit; opacity: .8; }

.composer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px); z-index: 6; }
.crow { display: flex; gap: 6px; align-items: flex-end; }
.crow textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); font-size: 16px; max-height: 140px; }
.clip { font-size: 22px; cursor: pointer; }
.att-list { display: flex; flex-wrap: wrap; gap: 6px; }
.att-list:not(:empty) { margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; max-width: 100%; }
.chip small { color: var(--text-3); }
.chip button { border: 0; background: none; padding: 2px 6px; cursor: pointer; color: var(--text-3); }
.clipline { flex-direction: row !important; align-items: center; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; cursor: pointer; color: var(--accent) !important; }

.viewer { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; }
.vbody { flex: 1; overflow: auto; padding: 12px; }
.vimg { max-width: 100%; display: block; margin: 0 auto; border-radius: 8px; }
.paper { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; font-size: 15px; line-height: 1.7; }
.code { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; margin: 0; }
.csv { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.csv table { border-collapse: collapse; font-size: 13px; }
.csv th, .csv td { border: 1px solid var(--border); padding: 5px 8px; white-space: nowrap; text-align: left; }
.csv th { background: var(--surface-2); }

.sheet-wrap { position: fixed; inset: 0; z-index: 30; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { margin: 0; font-size: 17px; }
.flist { display: flex; flex-direction: column; gap: 6px; }
.devs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.devs li { display: flex; align-items: center; gap: 8px; }
.devs small { color: var(--text-3); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.dot.on { background: var(--ok); }

.md h1 { font-size: 19px; margin: 4px 0 10px; } .md h2 { font-size: 16.5px; margin: 14px 0 6px; } .md h3 { font-size: 15px; margin: 12px 0 4px; }
.md p { margin: 6px 0; } .md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--col); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--col); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; }
.spinner.big { width: 30px; height: 30px; border-width: 3px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); text-align: center; }

.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.thumb { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; border-radius: 6px; }
.thumb img:not([src]) { visibility: hidden; }
.thumb span { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
