/* =========================================================================
 * style.css — 문서 자동 작성기
 * ========================================================================= */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #16203a;
  --ink-soft: #5b6478;
  --line: #e2e7f0;
  --brand: #1e3a8a;
  --brand-soft: #eef2ff;
  --accent: #2563eb;
  --ok: #0f8a5f;
  --warn: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nanum Gothic", "NanumGothic", "Malgun Gothic", -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; color: var(--brand); }
.brand i { font-size: 20px; }
.header-actions { display: flex; gap: 8px; }

.steps {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}
.step b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}
.step.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.step.active b { background: #fff; color: var(--brand); }
.step.done { color: var(--ok); border-color: #bfe3d3; background: #f0fbf6; }
.step.done b { background: var(--ok); color: #fff; }

/* -------------------------------------------------------------------- main */
.app-main { max-width: 980px; margin: 0 auto; padding: 26px 20px 60px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 30px;
}
.panel.center { text-align: center; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel-title { font-size: 22px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.02em; }
.panel-sub { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }
.section-label { font-size: 14px; font-weight: 800; color: var(--ink-soft); margin: 26px 0 10px; }
.section-label:first-of-type { margin-top: 4px; }
.empty { color: var(--ink-soft); font-size: 14px; margin: 0 0 8px; }

/* ------------------------------------------------------------------- cards */
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 14px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  font-family: inherit;
}
.type-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.type-card i { font-size: 30px; color: var(--brand); }
.type-card .type-name { font-weight: 800; font-size: 16px; }
.type-card .type-hint { font-size: 12px; color: var(--ink-soft); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tpl-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  padding: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.14s ease, transform 0.14s ease;
}
.tpl-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tpl-card .tpl-name { font-weight: 800; font-size: 15px; }
.tpl-card .tpl-desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }
.tpl-card .tpl-fields { font-size: 11.5px; color: var(--accent); font-weight: 700; margin-top: 4px; }
.tpl-card.uploaded { border-color: #cfe0ff; background: #fbfdff; }

/* ---------------------------------------------------------------- dropzone */
.dropzone {
  border: 2px dashed #c4cede;
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  background: #fafbff;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--brand-soft); }
.dropzone i { font-size: 26px; color: var(--accent); }
.dropzone p { margin: 8px 0 0; font-size: 14px; }
.dropzone .drop-hint { font-size: 12.5px; color: var(--ink-soft); }
.drop-status { margin-top: 12px; }

/* ------------------------------------------------------------------- forms */
.doc-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px 18px; }
.field-row { display: flex; flex-direction: column; gap: 6px; }
.field-row.wide { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.field-key { font-weight: 500; font-size: 11px; color: #94a0b8; background: var(--bg); border-radius: 5px; padding: 1px 6px; }
.field-help { font-size: 11.5px; color: var(--ink-soft); margin: 2px 0 0; }
.field-input { position: relative; display: flex; }

input[type="text"], input[type="date"], input[type="number"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
select, input[type="date"] { padding-right: 12px; }
textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.ai-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 30px; height: 30px;
  border: none;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  cursor: pointer;
  transition: background 0.14s ease;
}
.ai-btn:hover { background: #dbe4ff; }

.form-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.primary-btn, .ghost-btn, .mini {
  font-family: inherit;
  font-weight: 800;
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.14s ease, border-color 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.primary-btn {
  background: var(--brand);
  color: #fff;
  border: 1.5px solid var(--brand);
  padding: 11px 20px;
  font-size: 15px;
}
.primary-btn:hover:not(:disabled) { background: #16296b; transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.65; cursor: not-allowed; }
.ghost-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
  padding: 9px 15px;
  font-size: 13.5px;
}
.ghost-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ghost-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mini { padding: 7px 12px; font-size: 12.5px; border: 1.5px solid var(--line); background: var(--surface); }
.mini.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.mini:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------- ai panel */
.field-ai:empty { display: none; }
.ai-box {
  margin-top: 8px;
  padding: 13px 14px;
  border: 1.5px solid #cfe0ff;
  background: #f7faff;
  border-radius: 11px;
}
.ai-box.loading { color: var(--ink-soft); font-size: 13px; }
.ai-box.warn { border-color: #f5c2c0; background: #fff5f4; color: var(--warn); font-size: 13px; }
.ai-head { font-size: 12.5px; font-weight: 800; color: var(--brand); margin-bottom: 7px; }
.ai-text { font-size: 13.5px; white-space: pre-wrap; }
.ai-actions { display: flex; gap: 7px; margin-top: 11px; flex-wrap: wrap; }

/* ------------------------------------------------------------------- misc */
.ok { color: var(--ok); font-size: 13px; margin: 6px 0 0; }
.warn { color: var(--warn); font-size: 13px; }
.tag {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 7px;
}
.bulk-note {
  background: #f0fbf6;
  border: 1.5px solid #bfe3d3;
  color: #0b6b4a;
  border-radius: 11px;
  padding: 12px 15px;
  font-size: 13.5px;
  margin-bottom: 20px;
}
.bulk-preview { margin-top: 22px; font-size: 13.5px; }
.bulk-preview summary { cursor: pointer; font-weight: 800; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; margin-top: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; white-space: nowrap; }
th { background: var(--bg); font-weight: 800; }

.loading { text-align: center; color: var(--ink-soft); padding: 40px 0; font-size: 14px; }
.loading i { margin-right: 6px; }

/* ---------------------------------------------------------------- history */
.recent { margin-top: 30px; }
.recent-title { font-size: 14px; font-weight: 800; color: var(--ink-soft); margin: 0 0 10px; }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13.5px;
}
.recent-name { flex: 1; font-weight: 700; }
.recent-date { color: var(--ink-soft); font-size: 12px; }

/* ------------------------------------------------------------------- done */
.done-icon { font-size: 54px; color: var(--ok); margin-bottom: 8px; }
.result-list { display: flex; flex-direction: column; gap: 8px; max-width: 520px; margin: 22px auto 0; }
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 15px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
}
.result-item:hover { border-color: var(--accent); background: var(--brand-soft); }
.result-item i { color: var(--brand); }
.final-actions { display: flex; gap: 10px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-title { font-size: 18px; font-weight: 800; margin: 0; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 6px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: #16203a;
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #7a1d15; }

.app-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 34px;
  color: var(--ink-soft);
  font-size: 12.5px;
}

@media (max-width: 640px) {
  .panel { padding: 20px 16px 24px; }
  .panel-title { font-size: 19px; }
  .type-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .type-card { padding: 18px 10px; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
}
