:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --sunk: #10131a;
  --line: #2a2f3a;
  --line-soft: #232833;
  --text: #e9ecf2;
  --muted: #9aa2b1;
  --dim: #6f7889;
  --accent: #4ec9a5;
  --accent-2: #5b9dff;
  --nav-link: #9ec5ff;
  --nav-link-hover: #c8e0ff;
  --ok: #47c08a;
  --bad: #ef6b6b;
  --warn: #e3b341;
  --radius: 14px;
  --radius-sm: 10px;
  --lift: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 30px -24px rgba(0, 0, 0, .9);
  --ring: 0 0 0 3px rgba(78, 201, 165, .18);
  --topbar-h: 53px;
  --quotehead-h: 96px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
        "Noto Sans KR", Segoe UI, Roboto, sans-serif;
  /* 한국어는 낱말 가운데서 끊으면 읽기 나쁘다('말합니 / 다.'). 어절을 지킨다. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 20, 26, .9);
  backdrop-filter: saturate(140%) blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 19px; color: var(--text); letter-spacing: -0.3px;
}
.brand:hover { text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: -2px; }
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar nav a { color: var(--text); font-size: 14px; }
.topbar nav a.menu-link {
  color: var(--nav-link);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar nav a.menu-link:hover {
  color: var(--nav-link-hover);
  text-decoration: none;
}
.topbar .who { color: var(--muted); font-size: 13px; }
.ghost {
  border: 1px solid var(--line); padding: 5px 12px; border-radius: 8px;
  color: var(--muted) !important;
}
.topbar .start {
  padding: 6px 14px; border-radius: 8px; font-weight: 700; font-size: 13.5px;
  background: var(--accent); color: #07130f !important;
}
.topbar .start:hover { text-decoration: none; filter: brightness(1.08); }

main { max-width: 1060px; margin: 0 auto; padding: 26px 22px 60px; }
main.wide-main { max-width: 1500px; }
.col { max-width: 900px; margin: 0 auto; }
.narrow { max-width: 460px; margin: 40px auto; }

footer {
  border-top: 1px solid var(--line); padding: 18px 22px;
  color: var(--muted); font-size: 12px; text-align: center;
}

h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: -0.5px; font-weight: 700; }
h2 { font-size: 16.5px; margin: 0 0 12px; letter-spacing: -0.2px; }
h3 { font-size: 13.5px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
p.lead { color: var(--muted); margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

.sectionhead {
  display: flex; align-items: center; gap: 12px;
  margin: 30px 0 12px; font-size: 12.5px; font-weight: 700;
  color: var(--dim); letter-spacing: .4px;
}
.sectionhead::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.pagehead, .quotehead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 8px;
}
.quotehead {
  position: sticky;
  top: var(--topbar-h);
  z-index: 12;
  margin: 0 -22px 8px;
  padding: 10px 22px 14px;
  background: rgba(15, 17, 21, .94);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.quotehead h1 { margin-bottom: 4px; }
.quotehead .lead { margin-bottom: 0; }
.pagehead form, .quotehead form { margin: 0; }
.headacts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.headacts form { margin: 0; }
.headacts button, .headacts .btn { margin-top: 0; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--lift);
}
.card > h2 { margin-bottom: 6px; }
.card > .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; max-width: 76ch; }
.card p { max-width: 82ch; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.grid.tight { gap: 10px 14px; }
@media (max-width: 980px) {
  .grid.three, .grid.four { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
}

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 5px; }
.grid.tight label { margin-top: 4px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--sunk); color: var(--text);
  font: inherit; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: rgba(78, 201, 165, .6); box-shadow: var(--ring);
}
textarea { min-height: 74px; resize: vertical; }
input[type=file] { color: var(--muted); font-size: 13px; padding: 8px 0; }
.card input[type=text], .card input[type=email], .card input[type=password],
.card input[type=date], .card select, .card textarea { max-width: 560px; }
.grid.tight input, .grid.tight select { max-width: none; }

button, .btn {
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 16px;
  background: var(--accent); color: #07130f; font: inherit; font-weight: 600;
  cursor: pointer; margin-top: 14px; transition: filter .12s, background .12s, border-color .12s;
}
button:hover, .btn:hover { filter: brightness(1.07); }
button:disabled { opacity: .55; cursor: default; filter: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { display: inline-block; text-decoration: none; }
.btn:hover { text-decoration: none; }
button.sub, .btn.sub {
  background: var(--panel-2); color: var(--text) !important; border-color: var(--line);
}
button.sub:hover, .btn.sub:hover { border-color: #3f4a5e; filter: none; background: #232833; }
button.danger {
  background: transparent; color: var(--bad); border-color: #4a333c;
}
button.danger:hover { filter: none; background: rgba(239, 107, 107, .1); }
button.tiny, .btn.tiny { padding: 5px 10px; font-size: 12px; margin: 0; }
form.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
form.inline input, form.inline select { width: auto; margin: 0; }
form.inline button { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 12px; white-space: nowrap; border-bottom-color: var(--line); }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; white-space: nowrap; }
td .note { color: var(--dim); font-size: 12px; }
td .note:empty { display: none; }
td .note.bad { color: var(--bad); }
td form { display: inline-block; margin: 0; }

table.kv th { width: 90px; }
table.kv tr.grand th, table.kv tr.grand td {
  border-top: 1px solid var(--line); font-size: 15px; color: var(--text); font-weight: 700;
}
table.mini { margin-top: 14px; font-size: 12.5px; }
table.mini th, table.mini td { padding: 7px 8px; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: rgba(71,192,138,.12); border: 1px solid rgba(71,192,138,.35); }
.flash.bad { background: rgba(239,107,107,.12); border: 1px solid rgba(239,107,107,.35); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.pill.ready { color: var(--ok); border-color: rgba(71,192,138,.4); }
.pill.failed { color: var(--bad); border-color: rgba(239,107,107,.4); }
.pill.queued, .pill.processing, .pill.warn { color: var(--warn); border-color: rgba(227,179,65,.4); }
.pill.open { color: var(--accent-2); border-color: rgba(91,157,255,.4); }
.pill .spin {
  display: inline-block; width: 9px; height: 9px; margin-right: 5px;
  vertical-align: -1px; border-radius: 50%;
  border: 1.5px solid currentColor; border-top-color: transparent;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pill .spin { animation-duration: 2.4s; } }

/* ── 첫 화면 ─────────────────────────────────────────────── */
.hero { padding: 30px 0 10px; }
.hero h1 { font-size: 36px; letter-spacing: -1px; }
.hero .lead { font-size: 17px; max-width: 64ch; }
.hero .cta { display: flex; gap: 10px; margin-top: 6px; }
.card.plan .price { font-size: 22px; font-weight: 800; margin: 2px 0 8px; }
.card.plan .price span { font-size: 12px; color: var(--muted); font-weight: 400; }
ul.ticks { margin: 0 0 10px; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* ── 검색 폼 ─────────────────────────────────────────────── */
.searchgrid {
  display: grid; gap: 10px 14px; margin: 0;
  grid-template-columns: repeat(4, 1fr);
}
.searchgrid .wide { grid-column: span 2; }
.searchgrid label { margin: 0 0 4px; }
.searchgrid input, .searchgrid select { max-width: none; }
.searchgrid .act { display: flex; align-items: flex-end; gap: 8px; }
.searchgrid .act button, .searchgrid .act .btn { margin: 0; }
@media (max-width: 900px) {
  .searchgrid { grid-template-columns: 1fr 1fr; }
  .searchgrid .wide { grid-column: span 2; }
}

/* ── 작업 화면 (대화 + 견적서 패널) ──────────────────────── */
.worksplit {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
@media (max-width: 1120px) { .worksplit { grid-template-columns: 1fr; } }

.chatcol { position: sticky; top: calc(var(--topbar-h) + var(--quotehead-h)); }
@media (max-width: 1120px) {
  .chatcol { position: static; }
  .quotehead {
    position: sticky;
    top: var(--topbar-h);
  }
}

.chatlog {
  max-height: 56vh; overflow-y: auto; padding: 4px 2px 4px 0;
  display: flex; flex-direction: column; gap: 12px;
}
.turn { display: flex; flex-direction: column; gap: 5px; }
.turn .bubble {
  padding: 11px 14px; border-radius: 14px; font-size: 14px;
  border: 1px solid var(--line); background: var(--panel-2); max-width: 90%;
}
.turn .bubble p { margin: 0 0 8px; }
.turn .bubble p:last-child { margin: 0; }
.turn .bubble table { font-size: 12.5px; }
.turn.user { align-items: flex-end; }
.turn.user .bubble {
  background: rgba(78, 201, 165, .12); border-color: rgba(78, 201, 165, .3);
}
.changes {
  margin: 0; padding: 6px 10px 6px 24px; font-size: 12px; color: var(--ok);
  background: rgba(71,192,138,.07); border-left: 2px solid rgba(71,192,138,.4);
  border-radius: 0 8px 8px 0;
}
.sources { font-size: 11.5px; color: var(--dim); display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

.sayform { display: flex; gap: 8px; align-items: flex-end; margin-top: 14px; }
.sayform textarea { max-width: none; min-height: 62px; }
.sayform button { margin: 0; white-space: nowrap; }

.chatdrop { margin-top: 14px; border-radius: 10px; transition: background .15s, outline-color .15s; }
.chatdrop .sayform { margin-top: 0; }
.chatdrop .drop-hint { margin: 8px 0 0; }

.dropzone { position: relative; border-radius: 10px; transition: background .15s, outline-color .15s; }
.dropzone .drop-hint { margin: 10px 0 0; }
.dropzone.filedrop { padding: 2px 0; }
.dropzone.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
  background: rgba(99, 140, 255, .06);
}
.chatdrop.dragover textarea {
  border-color: var(--accent);
  background: rgba(99, 140, 255, .04);
}
.dropzone.uploading { opacity: .72; pointer-events: none; }

.panelcol .card:first-child { margin-top: 0; }
.card.sugg { border-color: rgba(227,179,65,.35); }
.suggrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line-soft);
}
.suggrow .label { font-size: 13.5px; }
.suggrow .note { font-size: 11.5px; color: var(--dim); }
.suggrow .acts { display: flex; gap: 6px; }

details.card > summary, details > summary {
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text);
}
details.card > summary { margin-bottom: 4px; }
details.rowitem {
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
details.rowitem > summary {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 400;
}
details.rowitem > summary b { font-weight: 700; }

.itemrows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.itemrow {
  display: grid; gap: 6px;
  grid-template-columns: 1.6fr 1.2fr 52px 62px 92px 1fr;
}
.itemrow input { max-width: none; padding: 7px 9px; font-size: 12.5px; }
@media (max-width: 720px) { .itemrow { grid-template-columns: 1fr 1fr; } }

.copyline { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.stampview {
  width: 84px; height: 84px; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 6px;
}

nav.tabs { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
nav.tabs a {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
nav.tabs a.on { color: #07130f; background: var(--accent); border-color: transparent; font-weight: 600; }
nav.tabs a:hover { text-decoration: none; }

.histbox { margin-top: 10px; }
.histbox table { font-size: 12.5px; }

/* ── 미리보기 창 ───────────────────────────────────────────
   display 는 여기서만 연다. .modal { display:flex } 를 기본으로 두면
   hidden 속성과 특이도가 겹쳐, 어떤 브라우저에서는 빈 모달이
   처음부터 화면을 덮는다. */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 14, .82);
  display: none; flex-direction: column;
}
.modal.open { display: flex; }
.modalbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted); flex: 0 0 auto;
}
.modalbar > div { display: flex; gap: 8px; align-items: center; }
.modal iframe {
  flex: 1 1 auto; width: 100%; min-height: 0; height: 100%;
  border: 0; background: #6b7280;
}

/* ── 공개 견적서 ─────────────────────────────────────────── */
body.publicpage { display: flex; flex-direction: column; min-height: 100vh; }
.publicbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  flex-wrap: wrap;
}
.publicbar .muted { font-size: 13px; margin-left: 8px; }
.publicbar .btn { margin: 0; }
iframe.publicdoc { flex: 1; width: 100%; border: 0; background: #6b7280; min-height: 70vh; }
.publicfoot {
  padding: 14px 20px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); text-align: center;
}

.pagehead .newquote {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pagehead .newquote select { min-width: 160px; margin: 0; }
.pagehead .newquote select[name="prompt_id"] { min-width: 180px; }
.formpick { margin-bottom: 16px; }
.formpick .grid { margin-top: 10px; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
