/* MarkItDown — vanilla CSS, no framework */
:root {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-soft: #111a2e;
  --panel: #131e34;
  --panel-2: #18253f;
  --border: #273550;
  --border-strong: #37496b;
  --text: #e8eefb;
  --muted: #97a6c2;
  --faint: #6c7c9b;
  --accent: #5eead4;
  --accent-2: #38bdf8;
  --accent-text: #052e2b;
  --danger: #fca5a5;
  --warning: #fcd34d;
  --success: #6ee7b7;
  --shadow: 0 18px 50px rgba(2, 6, 23, 0.45);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fc;
  --bg-soft: #edf1fa;
  --panel: #ffffff;
  --panel-2: #f8faff;
  --border: #dbe3f0;
  --border-strong: #c3d0e4;
  --text: #16223c;
  --muted: #53627f;
  --faint: #7a88a3;
  --accent: #0d9488;
  --accent-2: #0284c7;
  --accent-text: #ffffff;
  --danger: #b91c1c;
  --warning: #a16207;
  --success: #047857;
  --shadow: 0 18px 44px rgba(30, 41, 59, 0.12);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(960px 520px at 12% -12%, rgba(56, 189, 248, 0.14), transparent 65%),
    radial-gradient(760px 460px at 96% 0%, rgba(94, 234, 212, 0.11), transparent 62%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 24px 16px;
  gap: 20px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -1px;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.24);
}
.brand-mark span { font-size: 13px; margin-left: -3px; }
.brand-name { font-weight: 750; font-size: 20px; letter-spacing: -0.4px; }
.brand-tag {
  font-size: 11px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 3px 8px;
  border-radius: 999px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status-pill,
.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}
.status-pill .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 16%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
}
.status-pill.is-ready .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent);
  animation: none;
}
.status-pill.is-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent);
  animation: none;
}
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }

.offline-badge { color: var(--success); }
.offline-badge svg { width: 15px; height: 15px; fill: currentColor; }

.icon-button,
.install-button,
.primary-button,
.secondary-button,
.text-button {
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.icon-button:hover,
.install-button:hover,
.primary-button:hover,
.secondary-button:hover,
.text-button:hover { border-color: var(--border-strong); }
.icon-button:active,
.install-button:active,
.primary-button:active,
.secondary-button:active { transform: translateY(1px); }

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-size: 16px;
}
.install-button {
  min-height: 34px;
  padding: 6px 12px;
  background: var(--panel);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
.text-button {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  padding: 4px 6px;
  font-size: 12px;
}
.primary-button {
  padding: 11px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(56, 189, 248, 0.22);
}
.secondary-button {
  padding: 7px 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
}
.secondary-button:not(:disabled):hover { background: var(--border); }

/* ---------- main / dropzone ---------- */
.main { flex: 1; min-height: 0; display: flex; }

.dropzone {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 440px;
  padding: 36px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 22px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 72%, transparent), color-mix(in srgb, var(--bg-soft) 60%, transparent));
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.dropzone.is-dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  transform: scale(1.005);
}
.dropzone-inner { max-width: 560px; }
.dropzone-icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 19px;
  background: color-mix(in srgb, var(--accent) 13%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.dropzone-icon svg { width: 32px; height: 32px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone h1 { margin: 0 0 10px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -1px; }
.dropzone p { margin: 0 0 20px; color: var(--muted); line-height: 1.6; }
.dropzone .dropzone-hint { margin: 18px 0 0; font-size: 12px; color: var(--faint); letter-spacing: 0.2px; }
.dropzone .dropzone-note { margin: 8px 0 0; font-size: 11.5px; color: var(--faint); }

/* ---------- workspace ---------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 16px;
}
.file-panel,
.output-panel {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.file-panel { display: flex; flex-direction: column; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-heading h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0;
}
.file-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.file-list > li { display: flex; align-items: center; gap: 6px; }
.file-list > li > .file-item { flex: 1; min-width: 0; }
.retry-btn {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.retry-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.file-item:hover { background: var(--panel-2); }
.file-item.is-active { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.file-status { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--faint); }
.file-item[data-status="queued"] .file-status { background: var(--warning); }
.file-item[data-status="converting"] .file-status { background: var(--accent-2); animation: pulse 1s ease-in-out infinite; }
.file-item[data-status="done"] .file-status { background: var(--success); }
.file-item[data-status="error"] .file-status { background: var(--danger); }
.file-meta { min-width: 0; flex: 1; }
.file-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.file-sub { display: block; margin-top: 3px; color: var(--faint); font-size: 11px; }
.file-item[data-status="error"] .file-sub { color: var(--danger); }
.file-panel-footer { padding: 11px 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: 11.5px; }

.output-panel { display: flex; flex-direction: column; }
.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); }
.tab {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
}
.tab.is-active { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--accent); font-weight: 650; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stats { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-right: 4px; white-space: nowrap; }

.view { flex: 1; min-height: 0; overflow: auto; }
.raw-view { background: var(--panel-2); }
.raw-view pre { margin: 0; padding: 20px; min-height: 100%; }
.raw-view code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-view { padding: 26px 30px 40px; background: var(--panel); }
.empty-state { flex: 1; display: grid; place-items: center; color: var(--faint); font-size: 13px; }

.markdown-body { max-width: 860px; margin: 0 auto; line-height: 1.72; font-size: 14.5px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.3; margin: 1.5em 0 0.6em; }
.markdown-body h1 { font-size: 1.9em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.5em; padding-bottom: 0.25em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body table, .markdown-body pre { margin: 0 0 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; }
.markdown-body blockquote { padding: 2px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.markdown-body code { font-family: var(--mono); font-size: 0.9em; padding: 2px 5px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--border); }
.markdown-body pre { padding: 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); overflow-x: auto; }
.markdown-body pre code { padding: 0; border: 0; background: none; }
.markdown-body a { color: var(--accent-2); }
.markdown-body img { max-width: 100%; }
.markdown-body table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { padding: 7px 11px; border: 1px solid var(--border); text-align: left; }
.markdown-body th { background: var(--panel-2); }
.markdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* ---------- footer + toast ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
  color: var(--faint);
  font-size: 11.5px;
}
.footer p { margin: 0; }
.privacy { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
}
.toast.is-error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .file-panel { max-height: 210px; }
  .app-shell { padding: 14px 14px 12px; gap: 14px; }
  .dropzone { min-height: 360px; }
}
@media (max-width: 560px) {
  .brand-tag { display: none; }
  .topbar-actions { width: 100%; }
  .output-toolbar { align-items: flex-start; }
  .toolbar-actions { width: 100%; }
  .stats { width: 100%; }
  .preview-view { padding: 18px; }
}
