:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #1c2438;
  --ink-muted: #6b7a93;
  --line: #d6dee9;
  --line-soft: #e6ecf4;
  --accent: #8aaedb;
  --accent-dark: #5b89c4;
  --accent-soft: #eaf1fa;
  --btn: #8aaedb;
  --btn-dark: #5b89c4;
  --btn-ink: #ffffff;
  --error: #b93030;
  --error-bg: #fbeaea;
  --success: #2a8a3e;
}

* { box-sizing: border-box; }

html, body { height: 100%; overscroll-behavior: none; }
html { background: var(--bg); }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.screen { display: flex; flex-direction: column; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 56px 48px;
  text-align: center;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.brand-mark {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 3px;
  margin: 0 auto 28px;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px;
  background: var(--card);
  border-radius: 2px;
}
.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.login-card p {
  margin: 0 0 28px;
  color: var(--ink-muted);
  font-size: 14px;
}
#pin-input {
  width: 100%;
  font-family: "SF Mono", Menlo, "Consolas", monospace;
  font-size: 28px;
  letter-spacing: 0.5em;
  text-align: center;
  padding: 16px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  color: var(--ink);
  transition: border-color 0.15s;
}
#pin-input:focus {
  border-color: var(--ink);
}
.error {
  color: var(--error);
  margin-top: 12px;
  font-size: 13px;
  min-height: 20px;
  font-weight: 500;
}

/* ---------- App layout ---------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 40px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}
.brand-logo-link {
  display: inline-block;
  line-height: 0;
}
.login-logo {
  height: 88px;
  width: auto;
  display: block;
  margin: 0 auto 22px;
}
.brand-logo {
  height: 56px;
  width: auto;
  display: block;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-dot {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  position: relative;
}
.brand-dot::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  background: var(--bg);
  border-radius: 1px;
}
.ghost {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 12px;
  transition: color 0.15s;
}
.ghost:hover { color: var(--ink); }

main {
  flex: 1;
  max-width: 828px;
  margin: 0 auto;
  padding: 56px 24px 48px;
  width: 100%;
}
main h2 {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  line-height: 1.1;
  background: linear-gradient(180deg, #5b89c4 0%, #8aaedb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle {
  color: var(--ink-muted);
  margin: 0 0 28px;
  font-size: 17px;
  font-weight: 500;
}
.intro-section { margin: 0 0 22px; }
.intro-lead {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 500;
  font-size: 15px;
}
.intro-list {
  margin: 0 0 0 4px;
  padding: 0 0 0 22px;
  color: var(--ink-muted);
  line-height: 1.65;
  font-size: 14.5px;
}
.intro-list li { margin-bottom: 3px; }
.methodology-note {
  margin: 28px 0 36px;
  padding: 16px 20px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- Mode tabs ---------- */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 0 auto 22px;
  background: var(--card);
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  width: fit-content;
}
.mode-tab {
  background: transparent;
  border: none;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  transition: all 0.15s;
}
.mode-tab:hover:not(.active) { color: var(--ink); }
.mode-tab.active {
  background: var(--ink);
  color: var(--btn-ink);
}

/* ---------- Record mode ---------- */
.mode-panel { display: flex; flex-direction: column; }
.mode-panel.hidden { display: none; }
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 24px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  min-height: 340px;
  justify-content: center;
}
#audio-mode .drop-zone { min-height: 340px; }
#text-mode .text-input { min-height: 340px; }
.record-timer {
  font-family: "SF Mono", Menlo, "Consolas", monospace;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--error);
  margin-bottom: 18px;
  font-variant-numeric: tabular-nums;
}
.mic-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--btn-ink);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
  position: relative;
  padding: 0;
}
.mic-btn:hover { background: #2d2d2d; }
.mic-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mic-btn .mic-icon { width: 38px; height: 38px; display: block; }
.mic-btn .stop-icon { width: 28px; height: 28px; display: none; }
.mic-btn.recording {
  background: var(--error);
  animation: pulse-record 1.4s ease-in-out infinite;
}
.mic-btn.recording:hover { background: #a02828; }
.mic-btn.recording .mic-icon { display: none; }
.mic-btn.recording .stop-icon { display: block; }
@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 48, 48, 0.5); }
  50% { box-shadow: 0 0 0 14px rgba(185, 48, 48, 0); }
}
.record-status {
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 500;
  text-align: center;
}
.record-status.recording { color: var(--error); }
.record-instructions {
  margin: 22px 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-muted);
  text-align: justify;
  hyphens: auto;
  max-width: 540px;
}

/* ---------- Text input ---------- */
.text-input {
  width: 100%;
  min-height: 220px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.text-input:focus { border-color: var(--ink); }
.text-input::placeholder { color: var(--ink-muted); opacity: 0.7; }

.text-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  gap: 16px;
  flex-wrap: wrap;
}
.char-count {
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.text-controls .primary {
  margin-top: 0;
  align-self: auto;
}
.primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.primary:disabled:hover { background: var(--btn); }

/* ---------- Drop zone ---------- */
.drop-zone {
  position: relative;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: 6px;
  padding: 72px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--ink);
  background: var(--accent-soft);
}
.drop-zone-content {
  pointer-events: none;
}
.drop-icon {
  width: 36px;
  height: 36px;
  color: var(--ink-muted);
  margin: 0 auto 14px;
  display: block;
}
.drop-text {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}
.drop-hint {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0;
}
#file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ---------- Processing ---------- */
.processing {
  text-align: center;
  padding: 72px 24px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#processing-status {
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
}
.processing-hint {
  color: var(--ink-muted);
  font-size: 13px;
}

/* ---------- Results ---------- */
.results {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.result-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 22px 24px 24px;
  position: relative;
}
.result-card.highlight {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.result-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 14px;
}
.result-card.highlight .result-label {
  color: var(--accent-dark);
}
.result-hint {
  font-size: 12px;
  color: var(--ink-muted);
  font-style: italic;
  margin-top: -10px;
  margin-bottom: 12px;
}
.result-text {
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--ink);
}

/* Rendered markdown inside processed result */
#processed-text {
  white-space: normal;
}
#processed-text > *:first-child { margin-top: 0; }
#processed-text > *:last-child { margin-bottom: 0; }
#processed-text h1,
#processed-text h2,
#processed-text h3,
#processed-text h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 1.4em 0 0.5em;
  line-height: 1.25;
  color: var(--ink);
}
#processed-text h1 { font-size: 22px; }
#processed-text h2 { font-size: 18px; }
#processed-text h3 { font-size: 16px; }
#processed-text h4 { font-size: 15px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
#processed-text p { margin: 0 0 0.9em; }
#processed-text ul,
#processed-text ol { margin: 0 0 1em; padding-left: 22px; }
#processed-text li { margin-bottom: 4px; }
#processed-text li > p { margin-bottom: 4px; }
#processed-text strong { font-weight: 600; color: var(--ink); }
#processed-text em { font-style: italic; }
#processed-text code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  background: rgba(0,0,0,0.05);
  padding: 1px 6px;
  border-radius: 3px;
}
#processed-text pre {
  background: rgba(0,0,0,0.05);
  padding: 14px 16px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 1em;
}
#processed-text pre code {
  background: transparent;
  padding: 0;
}
#processed-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 0 0 1em;
  color: var(--ink-muted);
  font-style: italic;
}
#processed-text table {
  border-collapse: collapse;
  margin: 0 0 1em;
  font-size: 14px;
  width: 100%;
}
#processed-text th,
#processed-text td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
#processed-text th {
  font-weight: 600;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--line);
}
#processed-text hr {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 1.6em 0;
}
#processed-text a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.collapsible {
  position: relative;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.collapsible.collapsed {
  max-height: 5.6em;
}
.collapsible.expanded {
  max-height: none;
}
.fade-overlay {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3em;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--card) 90%);
}
.collapsible.collapsed .fade-overlay {
  display: block;
}

.expand-btn {
  display: block;
  margin-top: 12px;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
  transition: color 0.15s;
}
.expand-btn:hover { color: var(--ink); }
.expand-btn::after {
  content: " ↓";
  display: inline-block;
  margin-left: 4px;
  transition: transform 0.2s;
}
.expand-btn.expanded::after {
  content: " ↑";
}
.copy-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink-muted);
  transition: all 0.15s;
}
.copy-btn:hover { color: var(--ink); border-color: var(--ink); }
.copy-btn.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.prompt-display {
  font-size: 12px;
  color: var(--ink-muted);
  padding: 14px 16px;
  background: var(--card);
  border-radius: 3px;
  border-left: 3px solid var(--accent);
  word-wrap: break-word;
}
.prompt-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 10px;
  font-size: 10px;
  color: var(--accent-dark);
}

.primary {
  background: var(--btn);
  color: var(--btn-ink);
  padding: 13px 28px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  align-self: center;
  margin-top: 12px;
  transition: background 0.15s;
}
.primary:hover { background: #2d2d2d; }

/* ---------- Error ---------- */
.error-display {
  background: var(--error-bg);
  border: 1px solid #e5b5b5;
  color: var(--error);
  padding: 14px 18px;
  border-radius: 4px;
  margin-top: 20px;
  font-size: 14px;
  word-wrap: break-word;
}

.site-footer {
  background: #8aaedb;
  color: #fff;
  padding: 44px 56px 22px;
  font-size: 13px;
  letter-spacing: 0.01em;
  margin-top: 60px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 0.5fr 1.6fr 1.2fr 0.9fr;
  gap: 32px;
  align-items: start;
}
.footer-col-logo { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.footer-logo {
  height: 56px;
  width: auto;
  display: block;
}
.footer-company {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
}
.footer-tagline {
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
}
.footer-tagline strong { font-size: 14px; font-weight: 700; }
.footer-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 14px;
}
.footer-text {
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.92);
}
.footer-link-strong {
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.footer-link-strong:hover { opacity: 0.85; }
.footer-col a.footer-link-inline {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.footer-col a.footer-link-inline:hover { color: #fff; text-decoration: underline; }
.footer-col a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
}
.footer-col a:hover { text-decoration: underline; }
.footer-bottom-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  gap: 24px;
}
.footer-bottom-links a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.footer-bottom-links a:hover { color: #fff; }
.footer-copy { white-space: nowrap; }
@media (max-width: 800px) {
  .footer-bottom-row { flex-direction: column; text-align: center; }
}
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .site-footer { padding: 32px 24px 20px; }
}

@media (max-width: 640px) {
  header { padding: 16px 20px; }
  main { padding: 40px 18px 32px; }
  main h2 { font-size: 28px; }
  .login-card { padding: 40px 28px; }
  .drop-zone { padding: 52px 18px; }
  .result-card { padding: 18px 16px 20px; }
  .copy-btn { top: 12px; right: 12px; }
}
