:root {
  --navy: #0F2137;
  --navy-soft: #16304F;
  --steel: #2B4C7E;
  --ice: #EAF0F8;
  --amber: #E8A33D;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --text: #1B2430;
  --muted: #6B7686;
  --border: #E1E6ED;
  --mono: "IBM Plex Mono", monospace;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 33, 55, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 33, 55, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

a { color: inherit; }

/* ---------- Top bar (shared) ---------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.top-bar .brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.top-bar .brand-mark {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--steel);
  background: var(--ice);
  padding: 3px 8px;
  border-radius: 5px;
}

.top-bar .brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

.top-bar .session-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.top-bar .session-link:hover { color: var(--navy); }

/* ---------- Simple centered page (login / signup / result) ---------- */

.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.page-header { margin-bottom: 40px; }

.eyebrow {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--steel);
  margin-bottom: 12px;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.lede {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
  max-width: 560px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Form elements (shared) ---------- */

.field-group { margin-bottom: 28px; }

.section-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 14px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.field label .hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}

.template-status {
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--muted);
}

.output-checks {
  display: flex;
  gap: 12px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.check-item:has(input:checked) {
  border-color: var(--navy);
  background: var(--ice);
}

.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--navy);
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  transition: border-color 0.15s, background 0.15s;
}

select { cursor: pointer; }

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--steel);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(43, 76, 126, 0.12);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.segmented input[type="radio"] { display: none; }

.segmented label {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface);
  transition: background 0.15s, color 0.15s;
}

.segmented input[type="radio"]:checked + label {
  background: var(--navy);
  color: #fff;
}

.input-panel { margin-top: 20px; }

.submit-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.submit-btn:hover:not(:disabled) {
  background: var(--navy-soft);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.form-error,
.login-error {
  background: #FDECEC;
  color: #B3261E;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* ---------- Result page download rows ---------- */

.result-card { padding: 12px; }

.download-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  text-decoration: none;
  border-radius: 8px;
  color: var(--text);
}

.download-row:hover { background: var(--bg); }

.download-icon {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--navy);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
}

.download-label { font-size: 15px; font-weight: 600; }

.back-link {
  display: inline-block;
  margin-top: 24px;
  color: var(--steel);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Login / signup ---------- */

.login-page { max-width: 420px; padding-top: 90px; }
.login-card .field:last-of-type { margin-bottom: 22px; }
.switch-link { text-align: center; margin-top: 18px; }
.switch-link a { color: var(--steel); font-size: 13px; font-weight: 600; text-decoration: none; }

/* ---------- Workspace (main app: form + live preview) ---------- */

.workspace {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 28px;
  align-items: start;
}

.input-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

/* sticky는 데스크톱에서만 적용 (iOS Safari의 sticky+overflow 버그 회피를 위해
   기본값은 static으로 두고, 넓은 화면에서만 명시적으로 켠다) */
@media (min-width: 1001px) {
  .input-col {
    position: sticky;
    top: 28px;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
}

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; padding: 16px; gap: 20px; }
}

.input-col h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 4px;
}

.input-col .col-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 24px;
}

.preview-col {
  min-height: 480px;
}

.empty-state {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 80px 40px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
}

.empty-state .empty-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--steel);
  display: block;
  margin-bottom: 10px;
}

.empty-state p { max-width: 360px; margin: 0 auto; font-size: 14px; }

.loading-state {
  border-radius: var(--radius);
  padding: 80px 40px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.loading-state .spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--steel);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Preview fragment (slide-by-slide editor) ---------- */

.preview-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.preview-toolbar h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.preview-body {
  display: grid;
  grid-template-columns: 180px 1fr;
}

@media (max-width: 720px) {
  .preview-body { grid-template-columns: 1fr; }
}

.slide-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

@media (max-width: 720px) {
  .slide-nav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
}

.slide-nav button {
  text-align: left;
  padding: 9px 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}

.slide-nav button:hover { background: var(--ice); color: var(--navy); }

.slide-nav button.active {
  background: var(--navy);
  color: #fff;
}

.slide-content { padding: 24px; }

.slide-panel { display: none; }
.slide-panel.active { display: block; }

.slide-visual {
  border-radius: 10px;
  padding: 34px 30px;
  margin-bottom: 18px;
  min-height: 130px;
}

.slide-visual.cover { background: var(--slide-primary, var(--navy)); }
.slide-visual.content { background: var(--surface); border: 1px solid var(--border); }

.slide-visual .slide-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--slide-primary, var(--navy));
  margin-bottom: 4px;
}

.slide-visual.cover .slide-heading {
  color: var(--slide-accent, #fff);
  font-size: 27px;
}

.slide-visual .slide-sub { color: var(--slide-secondary, var(--steel)); font-size: 13px; }

.edit-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.ghost-btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

.ghost-btn:hover { background: var(--ice); }

.finalize-btn {
  padding: 11px 26px;
  border-radius: 8px;
  border: none;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.1s;
}

.finalize-btn:hover:not(:disabled) { background: var(--navy-soft); transform: translateY(-1px); }
.finalize-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
