*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #00B4D8;
  --blue-dark: #0096B8;
  --blue-light: #e0f7fb;
  --slate: #64748b;
  --slate-light: #f1f5f9;
  --border: #e2e8f0;
  --text: #1F2937;
  --text-muted: #64748b;
  --bg: #F8FAFC;
  --white: #ffffff;
  --red: #dc2626;
  --green: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login page ─────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0096B8 0%, #00B4D8 50%, #e0f7fb 100%);
}
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.login-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--blue-dark);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 32px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-weight: 500; font-size: 13px; color: var(--text); }
.form-group input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
  outline: none;
}
.form-group input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,180,216,.15); }
.btn-full { width: 100%; margin-top: 4px; }
.login-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: var(--red);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
}
.login-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 20px;
}

/* ── Header ─────────────────────────────────────── */
header {
  background: var(--blue-dark);
  color: white;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}
.logo { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; flex: 1; }
.header-right { display: flex; align-items: center; gap: 16px; }
.user-name { font-size: 13px; opacity: .85; }
.btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: white;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Tabs ─────────────────────────────────────── */
.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none;
  border: none;
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--blue); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-icon { font-size: 15px; }

/* ── Main ─────────────────────────────────────── */
main { max-width: 980px; margin: 24px auto; padding: 0 24px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Pane header ────────────────────────────── */
.pane-header { margin-bottom: 24px; }
.pane-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; color: #111827; }
.pane-header p { color: var(--text-muted); }

/* ── Card ─────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: #111827; }
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.card-header h3 { margin-bottom: 0; flex: 1; }

/* ── Drop Zone ─────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  background: var(--slate-light);
  transition: border-color .15s, background .15s;
  cursor: pointer;
  margin-bottom: 12px;
}
.drop-zone.drag-over { border-color: var(--blue); background: var(--blue-light); }
.drop-icon { font-size: 36px; margin-bottom: 12px; }
.drop-text { font-weight: 500; color: var(--text); margin-bottom: 4px; }
.drop-sub { color: var(--text-muted); font-size: 12px; margin: 4px 0; }
.drop-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── File List ─────────────────────────────────── */
.file-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}
.file-item-icon { font-size: 16px; flex-shrink: 0; }
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.file-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.file-item-remove:hover { color: var(--red); background: #fee2e2; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  padding: 8px 16px;
  border: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; box-shadow: var(--shadow); }
.btn-primary:not(:disabled):hover { background: var(--blue-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:not(:disabled):hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:not(:disabled):hover { background: var(--slate-light); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.btn-danger:hover { color: var(--red); background: #fee2e2; }

/* ── Actions row ─────────────────────────────── */
.action-row { display: flex; align-items: center; gap: 12px; margin: 20px 0; }

/* ── Progress ─────────────────────────────────── */
.progress-block {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.progress-msg { font-weight: 500; }
.progress-hint { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.inline-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result ─────────────────────────────────── */
.result-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}
.result-toolbar {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--slate-light);
  gap: 12px;
  flex-wrap: wrap;
}
.result-toolbar h3 { flex: 1; font-size: 15px; font-weight: 600; min-width: 0; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-content {
  padding: 24px;
  max-height: 720px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
}

/* Markdown output styling */
.result-content h1 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; color: var(--blue-dark); }
.result-content h2 { font-size: 17px; font-weight: 700; margin: 20px 0 10px; color: var(--blue-dark); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.result-content h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }
.result-content p { margin: 0 0 12px; }
.result-content ul, .result-content ol { margin: 0 0 12px 20px; }
.result-content li { margin-bottom: 4px; }
.result-content strong { font-weight: 600; }
.result-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.result-content blockquote { border-left: 3px solid var(--blue); padding-left: 12px; color: var(--text-muted); }
.result-content code { background: var(--slate-light); padding: 1px 4px; border-radius: 3px; font-family: 'Consolas', monospace; font-size: 13px; }
.result-content pre { background: var(--slate-light); padding: 12px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 12px; }

/* ── Edit area ──────────────────────────────── */
.edit-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  background: #fffef0;
}
.edit-textarea {
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  color: var(--text);
  background: var(--white);
}
.edit-textarea:focus { outline: none; border-color: var(--blue); }
.edit-actions { display: flex; gap: 8px; margin-top: 10px; }
.edit-saved-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
}

/* ── Templates list ──────────────────────────── */
.template-list { list-style: none; }
.template-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.template-item:last-child { border-bottom: none; }
.template-icon { font-size: 18px; flex-shrink: 0; }
.template-info { flex: 1; overflow: hidden; }
.template-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-date { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.empty-state { color: var(--text-muted); font-style: italic; padding: 8px 0; font-size: 13px; }

/* ── Convert output ──────────────────────────── */
.convert-output { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.convert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--slate-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
}
.convert-item.error { background: #fee2e2; border-color: #fecaca; }
.convert-item-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convert-item-size { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.convert-item-error { color: var(--red); font-size: 12px; flex: 1; }
.btn-download {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.btn-download:hover { background: var(--blue-dark); }

/* ── Fragment controls ───────────────────────── */
.mb-input-row { display: flex; align-items: center; gap: 10px; }
.mb-input {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.mb-input:focus { outline: none; border-color: var(--blue); }
.mb-label { color: var(--text-muted); font-size: 13px; }
.fragment-hint { color: var(--text-muted); font-size: 12px; margin-top: 8px; }

/* ── Toast ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  transition: opacity .2s;
  max-width: 90vw;
  text-align: center;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ── Interview Card ────────────────────────── */
.interview-card { margin-top: 8px; }
.interview-card h3 { margin-bottom: 10px; }
.optional-tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--slate-light);
  padding: 1px 7px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
}
.interview-textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
}
.interview-textarea:focus { outline: none; border-color: var(--blue); }
.interview-textarea::placeholder { color: var(--text-muted); }
.interview-file-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

/* ── Cross-analysis badge ───────────────────── */
.cross-badge {
  display: inline-block;
  background: #f59e0b;
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 8px;
}

/* ── Warnings Card ─────────────────────────── */
.warnings-card {
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 20px;
  overflow: hidden;
}
.warnings-ok { background: #f0fdf4; border-color: #86efac; }
.warnings-alert { background: #fffbeb; border-color: #fcd34d; }
.warnings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid;
}
.warnings-ok .warnings-header { background: #dcfce7; border-color: #86efac; color: #15803d; }
.warnings-alert .warnings-header { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.warnings-icon { font-size: 15px; flex-shrink: 0; }
.warnings-title { font-weight: 600; }
.warnings-body { padding: 14px 16px; font-size: 13px; line-height: 1.6; }
.warnings-ok .warnings-body { color: #166534; }
.warnings-alert .warnings-body { color: #78350f; }
.warnings-body h2 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin: 14px 0 4px; opacity: .75; }
.warnings-body h2:first-child { margin-top: 0; }
.warnings-body h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin: 14px 0 4px; opacity: .75; }
.warnings-body h3:first-child { margin-top: 0; }
.warnings-body p { margin: 0 0 6px; }
.warnings-body ul { margin: 0 0 6px 16px; }
.warnings-body li { margin-bottom: 2px; }

/* ── Utilities ─────────────────────────────── */
.hidden { display: none !important; }
