:root {
  --paper:      #efe8d6;
  --card:       #fbf6e8;
  --ink:        #1d1813;
  --ink-2:      #4a3f33;
  --muted:      #8a7a64;
  --rule:       #d6c9aa;

  --accent:     #a8311e;
  --accent-hover: #8a2918;
  --accent-soft: rgba(168, 49, 30, 0.10);

  --danger:     #9a2418;
  --danger-soft: rgba(154, 36, 24, 0.10);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}

/* ─── Card ──────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.app-card {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Brand ─────────────────────────────────────────────────── */

.brand {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.subtitle {
  margin: 6px 0 22px;
  font-size: 12px;
  color: var(--muted);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

/* ─── Inputs ────────────────────────────────────────────────── */

input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ─── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  user-select: none;
}
.btn.full { width: 100%; padding: 12px 16px; }
.btn.small { padding: 7px 12px; font-size: 12px; }

.btn.primary {
  background: var(--accent);
  color: #fbf2dd;
  border-color: var(--accent);
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--rule);
}
.btn.ghost:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink-2);
}

/* ─── Toggle ────────────────────────────────────────────────── */

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.toggle:hover { border-color: var(--ink-2); }

.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--ink-2);
  background: var(--card);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin-top: 2px;
}
.toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 4px;
  height: 9px;
  border: solid #fbf2dd;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.toggle-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.toggle-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* ─── Drop zone ─────────────────────────────────────────────── */

.drop-zone {
  border: 1.5px dashed var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.drop-icon {
  width: 30px;
  height: 30px;
  color: var(--accent);
  margin-bottom: 4px;
}

.drop-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.drop-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.link-like {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-name {
  margin: 8px 0 0;
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  padding: 5px 10px;
  border-radius: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Progress ──────────────────────────────────────────────── */

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ─── Result ────────────────────────────────────────────────── */

.result-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--rule);
  color: var(--accent);
  font-weight: 500;
}

textarea#result-text {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
}
textarea#result-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ─── Errors ────────────────────────────────────────────────── */

.error-msg {
  margin-top: 10px;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
}

.error-banner {
  background: var(--danger-soft);
  border: 1px solid rgba(154, 36, 24, 0.3);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ─── Utilities ─────────────────────────────────────────────── */

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .card { padding: 24px 20px; }
  .brand { font-size: 26px; }
  textarea#result-text { min-height: 280px; }
}
