:root {
  --bg: #f3f7fb;
  --bg-elevated: rgba(255, 255, 255, 0.88);
  --surface: #ffffff;
  --text: #132033;
  --muted: #576275;
  --border: #d5deea;
  --primary: #0a72f8;
  --primary-strong: #0657bd;
  --success: #117a55;
  --danger: #bf2044;
  --shadow: 0 24px 60px rgba(11, 33, 62, 0.18);
}

[data-theme="dark"] {
  --bg: #090d14;
  --bg-elevated: rgba(20, 28, 41, 0.84);
  --surface: #131c2b;
  --text: #e5edf8;
  --muted: #9cb0cc;
  --border: #2a3a51;
  --primary: #63a3ff;
  --primary-strong: #428ff8;
  --success: #2fbf87;
  --danger: #ff6a8a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

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

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

body {
  position: relative;
  padding: 2rem 1rem 3rem;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 8% 5%, #edf4ff, transparent 40%), var(--bg);
  color: var(--text);
  transition: background-color 180ms ease, color 180ms ease;
}

[data-theme="dark"] body {
  background: radial-gradient(circle at 8% 5%, #0f1f39, transparent 44%), var(--bg);
}

.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0.45;
}

.orb-a {
  width: 340px;
  height: 340px;
  background: linear-gradient(160deg, #1b7dff, #9cc4ff);
  top: -120px;
  right: -80px;
}

.orb-b {
  width: 300px;
  height: 300px;
  background: linear-gradient(180deg, #39c8a1, #91efd1);
  bottom: -120px;
  left: -100px;
}

.topbar {
  max-width: 960px;
  margin: 0 auto 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.7rem;
  background: linear-gradient(135deg, var(--primary), #00b4d8);
  color: #fff;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.brand-title {
  margin: 0;
  font-weight: 700;
}

.brand-subtitle {
  margin: 0.05rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.page-wrap {
  max-width: 960px;
  margin: 0 auto;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: rise-in 320ms ease-out;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.muted {
  color: var(--muted);
}

.health-line {
  margin: 0.45rem 0 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.health-dot {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 50%;
  background: #9caabf;
  box-shadow: 0 0 0 2px color-mix(in oklab, #9caabf 26%, transparent);
}

.health-dot.is-ok {
  background: var(--success);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--success) 26%, transparent);
}

.health-dot.is-bad {
  background: var(--danger);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--danger) 26%, transparent);
}

.mode-switch {
  margin: 1rem 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.mode-btn {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  color: var(--text);
  font-weight: 640;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-btn.is-active {
  border-color: color-mix(in oklab, var(--primary) 45%, white);
  background: color-mix(in oklab, var(--primary) 16%, var(--surface));
}

.mode-panel {
  animation: rise-in 220ms ease-out;
}

.dropzone {
  margin-top: 1rem;
  border: 2px dashed var(--border);
  border-radius: 1rem;
  padding: 1.5rem 1rem;
  text-align: center;
  background: color-mix(in oklab, var(--surface) 84%, transparent);
  transition: border-color 140ms ease, transform 140ms ease, background-color 140ms ease;
  cursor: pointer;
}

.dropzone.is-dragover {
  border-color: var(--primary);
  transform: translateY(-1px);
  background: color-mix(in oklab, var(--primary) 8%, var(--surface));
}

.dropzone.has-file {
  border-style: solid;
}

.drop-title {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 600;
}

.drop-subtitle {
  margin: 0.55rem 0;
  color: var(--muted);
}

.drop-footnote {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.file-info {
  margin: 0.8rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.field-label {
  display: block;
  font-weight: 600;
  margin: 0.9rem 0 0.45rem;
}

.input-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

.text-input,
.code-area {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.68rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.72rem 0.82rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.code-area {
  resize: vertical;
  min-height: 5.4rem;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  line-height: 1.4;
}

.text-input:focus-visible,
.code-area:focus-visible,
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.dropzone:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--primary) 55%, white);
  outline-offset: 2px;
}

.text-input:focus,
.code-area:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 18%, transparent);
}

.hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  font: inherit;
  border-radius: 0.7rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.primary-btn {
  margin-top: 1.2rem;
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  padding: 0.78rem 1rem;
  font-weight: 650;
}

.secondary-btn {
  padding: 0.62rem 0.95rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.ghost-btn {
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  color: var(--text);
  white-space: nowrap;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  transform: none;
  opacity: 0.6;
}

.status-panel {
  margin-top: 1rem;
}

.status-message {
  margin: 0 0 0.45rem;
  font-size: 0.93rem;
}

.progress-bar {
  width: 100%;
  height: 0.55rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 50%, var(--border));
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #00b4d8);
  transition: width 220ms ease;
}

.hidden {
  display: none !important;
}

.alert {
  margin-top: 1rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.8rem 0.9rem;
}

.alert.error {
  border-color: color-mix(in oklab, var(--danger) 42%, white);
  background: color-mix(in oklab, var(--danger) 10%, transparent);
  color: var(--danger);
}

.alert.success {
  border-color: color-mix(in oklab, var(--success) 42%, white);
  background: color-mix(in oklab, var(--success) 10%, transparent);
  color: color-mix(in oklab, var(--success) 75%, black);
}

.success-title {
  margin: 0;
  font-weight: 700;
}

.inline-link {
  display: inline-flex;
  margin-top: 0.75rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 650;
}

.inline-link:hover {
  text-decoration: underline;
}

.meta-grid {
  margin: 0.9rem 0 1.1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.meta-item {
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  padding: 0.66rem 0.75rem;
}

.meta-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.meta-value {
  margin: 0.22rem 0 0;
  font-size: 0.91rem;
  font-weight: 650;
  word-break: break-word;
}

.action-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.8rem;
}

.pill {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.68rem;
  color: var(--muted);
  font-size: 0.82rem;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
}

.pill.is-ok {
  border-color: color-mix(in oklab, var(--success) 40%, white);
  color: color-mix(in oklab, var(--success) 80%, black);
}

.gap-top {
  margin-top: 0.9rem;
}

@media (max-width: 720px) {
  body {
    padding-top: 1.1rem;
  }

  .topbar {
    align-items: flex-start;
  }

  .card {
    padding: 1.1rem;
  }

  .input-row,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }
}
