:root {
  --bg: #f4f6f8;
  --ink: #1a1f2c;
  --accent: #2b5db9;
  --muted: #64748b;
  --card: #ffffff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans KR", "Pretendard", system-ui, sans-serif;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 45%, #e8eef7 100%);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
}

.app-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e2e8f0;
}
.brand { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand[href],
.topbar-brand {
  color: inherit;
  text-decoration: none;
}
.brand[href]:hover,
.topbar-brand:hover {
  color: var(--accent, #2563eb);
}
.badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  color: #fff;
  background: #dc2626;
  border-radius: 999px;
  vertical-align: middle;
}

.nav-toggle {
  display: flex;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-between;
  flex: 0 0 auto;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: #334155;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* drawer: PC/모바일 공통 */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.45);
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-open .nav-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: min(82vw, 300px);
  height: 100%;
  height: 100dvh;
  background: #fff;
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.12);
  transform: translateX(-105%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  padding: calc(0.85rem + env(safe-area-inset-top, 0px)) 0 calc(1rem + env(safe-area-inset-bottom, 0px));
}
.sidebar.is-open { transform: translateX(0); }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1.1rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}
.drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #475569;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.6rem;
  overflow: auto;
  flex: 1;
}
.sidebar-nav a {
  display: block;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  border-radius: 10px;
}
.sidebar-nav a:hover {
  background: #f1f5f9;
  color: var(--accent);
}
.sidebar-logout {
  margin: 0.5rem 1rem 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}
.sidebar-logout button {
  width: 100%;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  min-height: 44px;
}
.sidebar-logout button:hover { color: #dc2626; border-color: #fecaca; }
body.drawer-open { overflow: hidden; }

.container {
  width: 100%;
  max-width: 720px;
  margin: 1.5rem auto 2rem;
  padding: 0 1rem;
}
.container-wide {
  max-width: 1180px;
}

.hero {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.hero h1 { margin: 0 0 0.75rem; font-size: clamp(1.35rem, 4vw, 1.75rem); }
.hero p { color: var(--muted); line-height: 1.6; }
.checklist {
  margin: 1.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--ink);
  line-height: 1.9;
}
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem 1rem calc(1.5rem + var(--safe-bottom));
}

.inline-form { display: inline; margin: 0; }
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 1.25rem 0;
}
.stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.stat-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.35rem; }
.stat-value { font-size: 1.2rem; font-weight: 700; word-break: break-all; }

/* auth */
.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand {
  text-align: center;
  font-weight: 700;
  font-size: 1.35rem;
  margin-bottom: 1.25rem;
}
.brand-link {
  color: inherit;
  text-decoration: none;
}
.auth-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.auth-card h1 {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  text-align: center;
}
.auth-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}
.auth-form input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 16px; /* iOS zoom 방지 */
}
.auth-form input:focus {
  outline: 2px solid #c7d2fe;
  border-color: var(--accent);
}
.auth-form .btn-primary {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  border: none;
  border-radius: 10px;
  background: #4f46e5;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-form .btn-primary:hover { background: #4338ca; }
.alert {
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.alert-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.auth-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 1rem;
}

/* documents */
.docs-page .docs-header {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.docs-page h1,
.doc-view h1,
.doc-view .doc-title-text {
  margin: 0;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  word-break: break-word;
}
.doc-title-block { min-width: 0; }
.doc-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0 0.75rem;
  min-width: 0;
}
.doc-title-text {
  flex: 0 1 auto;
  min-width: 0;
  line-height: 1.35;
}
.doc-title-edit {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  padding: 0;
}
.doc-title-edit:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}
.doc-title-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
}
.doc-title-form[hidden] { display: none !important; }
.doc-title-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
}
.doc-title-save,
.doc-title-cancel {
  flex: 0 0 auto;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
}
.doc-title-save {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}
.doc-title-cancel:hover { background: #f8fafc; }
.docs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}
.upload-form {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-width: 0;
}
.btn-upload {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 42px;
}
.btn-upload:hover { background: #f1f5f9; }
.hint { color: var(--muted); font-size: 0.85rem; }
.upload-hint-short { display: none; }
.search-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 220px;
  max-width: 360px;
  justify-content: flex-end;
}
.search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  color: #334155;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
}
.search-toggle:hover { background: #f1f5f9; }
.search-form {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}
.search-form input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 16px;
}
.search-form button {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.docs-count { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 0.9rem;
}
.doc-card {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.1rem 0.9rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  min-height: 170px;
  display: flex;
  flex-direction: column;
}
.doc-card.status-완료.type-proof { background: linear-gradient(to top, #ffecec 0%, #fff 40%); }
.doc-card.status-완료.type-copy { background: linear-gradient(to top, #ecf5ff 0%, #fff 40%); }
.doc-card.status-완료.type-style { background: linear-gradient(to top, #ecfdf5 0%, #fff 40%); }
.doc-card.status-완료.type-translate { background: linear-gradient(to top, #f5f0ff 0%, #fff 40%); }
.btn-delete {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  width: 2rem;
  height: 2rem;
}
.btn-delete:hover { color: #ef4444; }
.doc-title {
  margin: 0 1.5rem 0.4rem 0;
  font-size: 1.05rem;
  line-height: 1.35;
  word-break: break-word;
}
.doc-meta, .doc-date { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0; }
.doc-preview {
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.45;
  flex: 1;
  margin: 0.5rem 0 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.65rem;
  margin-top: auto;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.doc-status { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.doc-process {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}
.doc-process.type-proof { color: #dc2626; }
.doc-process.type-copy { color: #2563eb; }
.doc-process.type-style { color: #16a34a; }
.doc-process.type-translate { color: #7c3aed; }
.ai-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.ai-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid;
  background: #fff;
  user-select: none;
  line-height: 1.3;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ai-pill-proof {
  border-color: #fca5a5;
  color: #dc2626;
  background: #fef2f2;
}
.ai-pill-proof:hover,
.ai-edit-radio:checked + .ai-pill-proof {
  border-color: #b91c1c;
  color: #fff;
  background: #dc2626;
}
.ai-pill-copy {
  border-color: #93c5fd;
  color: #2563eb;
  background: #eff6ff;
}
.ai-pill-copy:hover,
.ai-edit-radio:checked + .ai-pill-copy {
  border-color: #1d4ed8;
  color: #fff;
  background: #2563eb;
}
.ai-pill-style {
  border-color: #86efac;
  color: #16a34a;
  background: #f0fdf4;
}
.ai-pill-style:hover,
.ai-edit-radio:checked + .ai-pill-style {
  border-color: #15803d;
  color: #fff;
  background: #16a34a;
}
.ai-edit-radio:focus-visible + .ai-pill {
  outline: 2px solid #2b5db9;
  outline-offset: 2px;
}
.btn-start {
  border: none;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.35rem 0;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  margin-left: auto;
}
.btn-start:hover { color: var(--accent); }
.doc-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.35rem 0;
}
.doc-link:hover { color: var(--accent); }
.empty-state {
  background: #fff;
  border-radius: 14px;
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
}
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0 0.5rem;
  flex-wrap: wrap;
}
.pager a { color: var(--accent); text-decoration: none; padding: 0.4rem 0.6rem; }
.pager a.disabled { pointer-events: none; color: #cbd5e1; }

/* doc view / editor */
.back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--accent); }
.doc-content {
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.7;
  max-height: min(70vh, 720px);
  overflow: auto;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  margin: 0;
  font-size: 0.98rem;
  -webkit-overflow-scrolling: touch;
}
.ai-panel {
  background: #fff;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  margin: 1rem 0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}
.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  align-items: center;
}
.btn-ai-start {
  border-radius: 999px;
  padding: 0.65rem 1.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  border: 2px solid;
  background: #fff;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  flex: 0 1 auto;
}
.btn-ai-start.type-proof {
  color: #dc2626;
  border-color: #dc2626;
}
.btn-ai-start.type-proof:hover:not(:disabled) {
  background: #dc2626;
  color: #fff;
}
.btn-ai-start.type-copy {
  color: #2563eb;
  border-color: #2563eb;
}
.btn-ai-start.type-copy:hover:not(:disabled) {
  background: #2563eb;
  color: #fff;
}
.btn-ai-start.type-style {
  color: #16a34a;
  border-color: #16a34a;
}
.btn-ai-start.type-style:hover:not(:disabled) {
  background: #16a34a;
  color: #fff;
}
.btn-ai-start:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-download {
  margin-left: auto;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.65rem 1.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  min-height: 44px;
  cursor: pointer;
  font-family: inherit;
  border: 2px solid #0f172a;
  background: #fff;
  color: #0f172a;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.btn-download:hover:not(:disabled) {
  background: #0f172a;
  color: #fff;
}
.btn-download:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary,
.btn-secondary {
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  flex: 1 1 auto;
}
.btn-primary {
  border: none;
  background: var(--accent, #2563eb);
  color: #fff;
}
.btn-primary:disabled,
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--ink);
}
.ai-progress {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.ai-progress.hidden { display: none; }
.ai-progress.is-running {
  border-color: #cbd5e1;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.06);
}
.ai-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.ai-progress-head strong {
  font-size: 0.92rem;
  color: var(--ink);
}
.ai-progress-pct {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  min-width: 3.2rem;
  text-align: right;
}
.progress-track {
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background-color: #38bdf8;
  width: 0;
  transition: width 0.35s ease;
  border-radius: 999px;
}
.progress-fill.type-proof { background-color: #dc2626; }
.progress-fill.type-copy { background-color: #2563eb; }
.progress-fill.type-style { background-color: #16a34a; }
.ai-progress.is-running .progress-track {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.ai-progress .hint {
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
}
.ai-progress-notes {
  margin: 0.65rem 0 0;
  padding-left: 1.1rem;
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.5;
}
.ai-progress-notes li { margin: 0.15rem 0; }
.ai-progress-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}
.btn-ai-stop {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 38px;
}
.btn-ai-stop:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}
.btn-ai-stop:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-ai-stop[hidden] { display: none !important; }
.ai-message { width: 100%; margin: 0; color: var(--muted); font-size: 0.9rem; }
.ai-message.error { color: #dc2626; }

/* download modal */
.dl-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.dl-modal[hidden] { display: none !important; }
.dl-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}
.dl-panel {
  position: relative;
  width: min(100%, 28rem);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  padding: 1.15rem 1.15rem 1rem;
}
.dl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.dl-head h2 {
  margin: 0;
  font-size: 1.1rem;
}
.dl-x {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
}
.dl-x:hover { color: #0f172a; }
.dl-desc {
  margin: 0 0 0.85rem;
  color: #64748b;
  font-size: 0.9rem;
}
.dl-options {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.dl-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
}
.dl-option:has(input:checked) {
  border-color: #93c5fd;
  background: #eff6ff;
}
.dl-option strong {
  display: block;
  font-size: 0.88rem;
  word-break: break-all;
  margin-bottom: 0.2rem;
}
.dl-option small {
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.35;
}
.dl-option input {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  accent-color: #2563eb;
}
.dl-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.dl-actions .btn-secondary,
.dl-actions .btn-primary {
  flex: 0 1 auto;
  min-width: 5.5rem;
}

.view-tabs {
  display: none;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.view-tab {
  flex: 1;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}
.view-tab.active {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

.doc-split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 1rem;
  align-items: start;
}
.editor-pane { min-width: 0; }
.suggestions-panel {
  background: #fff;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  max-height: min(70vh, 720px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.suggestions-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.65rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.suggestions-head h2 { margin: 0; font-size: 1.05rem; }
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.btn-tiny {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}
.btn-tiny:hover { background: #f8fafc; }
.sug-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.doc-content .mark {
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 700;
  cursor: pointer;
}
/* 미적용: 볼드만 표시 */
.doc-content .mark.pending {
  background: transparent;
  color: inherit;
}
/* 적용: 유형별 상징색 */
.doc-content .mark.applied.type-proof {
  color: #dc2626;
  background: #fee2e2;
}
.doc-content .mark.applied.type-copy {
  color: #2563eb;
  background: transparent;
}
.doc-content .mark.applied.type-style {
  color: #16a34a;
  background: transparent;
}
.doc-content .mark.flash {
  outline: 2px solid #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  border-radius: 3px;
}
.suggestion-item {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.suggestion-item.is-focused {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background: #eff6ff;
}
.suggestion-item.is-applied.type-proof {
  background: #fef2f2;
  border-color: #fecaca;
}
.suggestion-item.is-applied.type-copy {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.suggestion-item.is-applied.type-style {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.toggle-apply {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  flex: 0 0 auto;
  color: #94a3b8;
}
.suggestion-item.is-applied.type-proof .toggle-apply {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.suggestion-item.is-applied.type-copy .toggle-apply {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.suggestion-item.is-applied.type-style .toggle-apply {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.sug-body { min-width: 0; flex: 1; }
.sug-row-top {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}
.sug-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
  line-height: 1.45;
  min-width: 0;
  flex: 1;
}
.sug-edit-btn {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 0.15rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 0;
}
.sug-edit-btn:hover:not(:disabled) {
  color: #0f172a;
  background: #f1f5f9;
}
.sug-edit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.sug-edit-box {
  margin-top: 0.45rem;
}
.sug-edit-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.9rem;
}
.sug-edit-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: #2563eb;
}
.sug-orig {
  color: #475569;
  font-weight: 700;
  word-break: break-word;
}
.suggestion-item.is-applied .sug-orig {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.sug-new { font-weight: 700; word-break: break-word; }
.suggestion-item.type-proof .sug-new { color: #dc2626; }
.suggestion-item.type-copy .sug-new { color: #2563eb; }
.suggestion-item.type-style .sug-new { color: #16a34a; }
.suggestion-item.is-applied.type-proof .sug-new {
  color: #dc2626;
  background: #fee2e2;
  border-radius: 3px;
  padding: 0 2px;
}
.suggestion-item.is-applied.type-copy .sug-new { color: #2563eb; }
.suggestion-item.is-applied.type-style .sug-new { color: #16a34a; }
.sug-arrow { color: var(--muted); }
.sug-meta { margin-top: 0.35rem; color: var(--muted); font-size: 0.8rem; }
.empty-hint { margin: 0.5rem 0; }

/* tablet */
@media (max-width: 960px) {
  .doc-split {
    grid-template-columns: 1fr;
  }
  .doc-content,
  .suggestions-panel {
    max-height: min(55vh, 520px);
  }
}

/* mobile */
@media (max-width: 720px) {
  .container {
    margin: 1rem auto 1.5rem;
    padding: 0 0.85rem;
  }
  .hero { padding: 1.25rem; }
  .stat-row { grid-template-columns: 1fr; }

  .docs-toolbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .upload-form { flex: 1; min-width: 0; flex-wrap: nowrap; }
  .upload-hint-full { display: none; }
  .upload-hint-short {
    display: inline;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .search-wrap {
    flex: 0 0 auto;
    max-width: none;
    position: relative;
  }
  .search-toggle { display: inline-flex; }
  .search-wrap .search-form {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    width: min(calc(100vw - 1.7rem), 360px);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.45rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    z-index: 20;
  }
  .search-wrap.is-open .search-form { display: flex; }
  .search-wrap.is-open .search-toggle {
    border-color: #94a3b8;
    background: #f8fafc;
  }
  .card-grid { grid-template-columns: 1fr; }

  .ai-actions .btn-ai-start {
    flex: 1 1 auto;
    min-width: 0;
  }
  .ai-actions .btn-download {
    margin-left: auto;
    flex: 0 0 auto;
  }

  .view-tabs { display: flex; }
  .pane-panel { display: none; }
  .pane-panel.is-active { display: block; }
  .suggestions-panel.pane-panel.is-active {
    display: flex;
    flex-direction: column;
  }
  .doc-content {
    max-height: calc(100dvh - 12rem);
    min-height: 40vh;
  }
  .suggestions-panel {
    max-height: calc(100dvh - 12rem);
    min-height: 0;
    height: calc(100dvh - 12rem);
    box-shadow: none;
    padding: 0.85rem 0.1rem;
    background: transparent;
    overflow: hidden;
  }
  .suggestions-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .suggestions-panel .suggestions-head,
  .suggestions-list .suggestion-item {
    background: #fff;
  }
  .suggestions-panel .suggestions-head {
    padding: 0.75rem;
    margin-bottom: 0.65rem;
    border-radius: 12px;
    border-bottom: none;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  }
}

@media (max-width: 400px) {
  .ai-actions .btn-ai-start {
    flex: 1 1 auto;
  }
  .ai-actions .btn-download {
    flex: 0 0 auto;
  }
}


/* panel pages */
.panel-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.panel-card h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
}
.subhead {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 700;
}
.lead-muted { color: var(--muted); font-size: 0.92rem; line-height: 1.55; margin: 0 0 1rem; }
.notice-box {
  background: #f8fafc;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.notice-box ul { margin: 0; padding-left: 1.1rem; }
.pay-methods {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.pay-method {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.7rem;
  cursor: pointer;
  background: #fff;
  font-size: 0.92rem;
}
.pay-method:has(input:checked) {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 600;
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.product-btn {
  position: relative;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  padding: 0.9rem 0.5rem;
  cursor: pointer;
  text-align: center;
  line-height: 1.45;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.product-btn:hover { border-color: #818cf8; }
.product-btn.is-selected {
  border-color: #4f46e5;
  background: #eef2ff;
}
.product-btn.is-pulse {
  transform: scale(0.97);
}
.product-btn strong { display: block; font-size: 0.95rem; }
.product-btn span { font-size: 0.82rem; color: var(--muted); }
.product-btn .discount {
  display: inline-block;
  margin-left: 0.25rem;
  color: #15803d;
  font-style: normal;
  font-weight: 600;
  font-size: 0.75rem;
}
.product-count {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #4f46e5;
  color: #fff;
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}
.purchase-summary {
  margin-bottom: 1rem;
}
.purchase-summary .subhead {
  margin: 0 0 0.55rem;
}
.selected-list {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.selected-list:empty { display: none; }
.selected-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}
.selected-list li:last-child { border-bottom: 0; }
.selected-list .line-amount {
  display: block;
  margin-top: 0.15rem;
  font-style: normal;
  color: var(--muted);
  font-size: 0.82rem;
}
.selected-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.btn-qty {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: #334155;
}
.btn-remove {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}
.total-line { text-align: right; font-size: 1rem; margin: 0.75rem 0 0; }
.purchase-checkout {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 0.85rem;
}
.purchase-checkout .btn-primary {
  min-width: 8.5rem;
}
.purchase-checkout .btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.center-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.btn-primary {
  border: none;
  border-radius: 10px;
  background: #4f46e5;
  color: #fff;
  font-weight: 600;
  padding: 0.75rem 1.4rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn-primary:hover { background: #4338ca; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.75rem 1.2rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  background: #fff;
}
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th,
.data-table td {
  border: 1px solid #e2e8f0;
  padding: 0.65rem 0.55rem;
  vertical-align: top;
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  text-align: center;
}
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}
.status-ok { color: #15803d; font-weight: 600; }
.status-warn { color: #b45309; font-weight: 600; }
.status-bad { color: #b91c1c; font-weight: 600; }
.alert-ok {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.stack-form label {
  display: block;
  margin-bottom: 0.85rem;
}
.stack-form label span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.stack-form input,
.stack-form textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
}
.stack-form.narrow { max-width: 360px; }
.fb-block { margin-bottom: 0.65rem; }
.fb-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.fb-block.answer .fb-label { color: #3730a3; }
.fb-body {
  white-space: pre-wrap;
  background: #fff;
  border-left: 3px solid #94a3b8;
  padding: 0.55rem 0.7rem;
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}
.fb-block.answer .fb-body {
  background: #f8fafc;
  border-left-color: #6366f1;
}
.muted { color: var(--muted); }
.italic { font-style: italic; font-size: 0.85rem; }
.account-grid {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.account-avatar img,
.avatar-fallback {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e2e8f0;
}
.avatar-fallback {
  display: grid;
  place-items: center;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 700;
  font-size: 1.4rem;
}
.account-info p { margin: 0.35rem 0; font-size: 0.92rem; color: var(--muted); }
.account-info strong { color: var(--ink); font-weight: 600; }
.account-info .accent { color: #4f46e5; }
.soft-hr { border: 0; border-top: 1px solid #e2e8f0; margin: 1.5rem 0; }
.prose p, .prose li { color: var(--muted); line-height: 1.65; font-size: 0.95rem; }
.prose h2 { font-size: 1.05rem; margin: 1.4rem 0 0.55rem; color: var(--ink); }
.center-title { text-align: center; color: #19346b; }
.warn-list { color: #b91c1c !important; }
.warn-list li { color: #b91c1c; }
.tip-box {
  background: #f0f7ff;
  border-left: 5px solid #19346b;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 1.25rem 0;
}
.tip-box strong { color: #19346b; }
.faq-item { margin-bottom: 1.5rem; }
.faq-item h2 { font-size: 1rem; margin: 0 0 0.45rem; }
.nav-sep {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 0.45rem 0;
}
.nav-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: #ef4444;
  vertical-align: middle;
}
.topbar-balance {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4f46e5;
  padding-right: 0.25rem;
}
#nav-balance-value {
  display: inline-block;
  min-width: 1.5ch;
  transition: color 0.25s ease, transform 0.25s ease;
}
#nav-balance-value.is-updating {
  color: #dc2626;
  transform: scale(1.06);
}
.dash-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
}
.dash-links a {
  display: inline-flex;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.dash-links a:hover { background: #e0e7ff; color: #3730a3; }

@media (max-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }
  .product-btn {
    padding: 0.75rem 0.3rem 0.65rem;
  }
  .product-btn strong {
    font-size: 0.82rem;
  }
  .product-btn span {
    font-size: 0.72rem;
  }
  .product-btn .discount {
    display: block;
    margin: 0.15rem 0 0;
  }
  .account-grid { flex-direction: column; }
  .pay-methods { flex-direction: column; }
  .selected-list li {
    flex-wrap: wrap;
  }
}

/* —— DadmiDialog —— */
body.dd-open { overflow: hidden; }
.dd-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}
.dd-root[hidden] { display: none !important; }
.dd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.dd-panel {
  position: relative;
  width: min(100%, 22rem);
  margin: 0;
  padding: 1.35rem 1.25rem 1.15rem;
  border-radius: 18px;
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 18px 48px rgba(15, 23, 42, 0.18);
  text-align: center;
  transform: translateY(10px) scale(0.97);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.dd-root.is-open .dd-backdrop { opacity: 1; }
.dd-root.is-open .dd-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.dd-icon {
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  background: #e8eef8;
  color: #2b5db9;
}
.dd-root[data-variant="success"] .dd-icon {
  background: #e8f7ee;
  color: #15803d;
}
.dd-root[data-variant="error"] .dd-icon {
  background: #fdecec;
  color: #b91c1c;
}
.dd-root[data-variant="warn"] .dd-icon {
  background: #fff7e8;
  color: #b45309;
}
.dd-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.dd-msg {
  margin: 0 0 1.15rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #475569;
  white-space: pre-wrap;
  word-break: keep-all;
}
.dd-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: stretch;
}
.dd-btn {
  flex: 1;
  min-height: 2.65rem;
  border-radius: 12px;
  border: 0;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.dd-btn:active { transform: scale(0.98); }
.dd-btn-primary {
  background: #2b5db9;
  color: #fff;
}
.dd-btn-primary:hover { background: #234c98; }
.dd-root[data-variant="success"] .dd-btn-primary {
  background: #15803d;
}
.dd-root[data-variant="success"] .dd-btn-primary:hover { background: #166534; }
.dd-root[data-variant="error"] .dd-btn-primary {
  background: #b91c1c;
}
.dd-root[data-variant="error"] .dd-btn-primary:hover { background: #991b1b; }
.dd-btn-ghost {
  background: #f1f5f9;
  color: #334155;
}
.dd-btn-ghost:hover { background: #e2e8f0; }
.dd-btn[hidden] { display: none !important; }
.dd-icon[hidden] { display: none !important; }
