:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --bg-accent: #fff9ef;
  --ink: #161412;
  --muted: #6d625a;
  --brand: #136f63;
  --brand-dark: #0c4941;
  --highlight: #f6c177;
  --card: #ffffff;
  --stroke: #e7ddd2;
  --shadow: 0 18px 40px rgba(17, 14, 12, 0.12);
  --radius: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101516;
  --bg-accent: #151d1f;
  --ink: #f2ece3;
  --muted: #a69f96;
  --brand: #4ad4b8;
  --brand-dark: #3ba993;
  --highlight: #f2b86b;
  --card: #151b1d;
  --stroke: #263032;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, rgba(245, 234, 215, 0.7) 0%, var(--bg) 55%, #eee7dc 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

[data-theme="dark"] body {
  background: radial-gradient(circle at top left, rgba(31, 70, 65, 0.35) 0%, var(--bg) 55%, #0d1213 100%);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 48px;
  gap: 24px;
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-mark {
  background: var(--brand);
  color: white;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 12px;
  letter-spacing: 1px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: "Fraunces", serif;
  font-size: 1.4rem;
}

.brand-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.account-chip {
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--bg-accent);
  margin-left: 6px;
}

.page {
  flex: 1;
  padding: 0 48px 48px;
  position: relative;
  z-index: 2;
}

.hero {
  margin: 12px 0 32px;
}

.hero-card {
  background: var(--card);
  padding: 28px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
  position: relative;
  overflow: hidden;
}

.hero-card h1 {
  margin: 0 0 12px;
  font-family: "Fraunces", serif;
  font-size: 2rem;
}

.hero-note {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg-accent);
  border-radius: 10px;
  border: 1px dashed var(--stroke);
  font-size: 0.9rem;
}

.hero-classes {
  margin-top: 14px;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

.predict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-weight: 500;
}

input,
select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

[data-theme="dark"] input,
[data-theme="dark"] select {
  background: #0f1416;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 8px 18px rgba(29, 91, 95, 0.2);
}

.btn.disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  border-color: var(--stroke);
  color: var(--ink);
  background: transparent;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  position: relative;
  display: inline-block;
}

[data-theme="light"] .theme-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed currentColor;
  opacity: 0.6;
}

[data-theme="dark"] .theme-icon {
  border-color: transparent;
  background: currentColor;
}

[data-theme="dark"] .theme-icon::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  top: -1px;
  right: -1px;
  background: var(--card);
}

.nav-btn {
  border-color: var(--stroke);
  color: var(--ink);
  background: var(--bg-accent);
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(17, 14, 12, 0.1);
  border-color: var(--brand);
}

[data-theme="dark"] .nav-btn:hover {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.preview-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-title {
  font-size: 0.9rem;
  color: var(--muted);
}

.preview-image,
.preview-canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  object-fit: cover;
  background: #f0ece6;
}

[data-theme="dark"] .preview-image,
[data-theme="dark"] .preview-canvas {
  background: #0f1416;
}

.preview-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result {
  display: grid;
  gap: 12px;
}

.result-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.result-class {
  font-family: "Fraunces", serif;
  font-size: 1.6rem;
}

.result-confidence {
  font-size: 1.1rem;
  color: var(--brand-dark);
}

.result-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-top3 ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.result-top3 li {
  background: var(--bg-accent);
  padding: 8px 12px;
  border-radius: 10px;
}

.result-placeholder {
  color: var(--muted);
  font-size: 0.95rem;
}

.auth {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}

.auth-card {
  width: min(420px, 100%);
}

.auth-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.history .table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-accent);
}

.flash-wrap {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff7ed;
  color: #7a4f0f;
}

.flash.error {
  background: #fff1f2;
  color: #9f1239;
}

.flash.success {
  background: #ecfdf5;
  color: #166534;
}

.site-footer {
  padding: 20px 48px 30px;
  font-size: 0.85rem;
  color: var(--muted);
  position: relative;
  z-index: 2;
}

@media (max-width: 900px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
  }

  .page {
    padding: 0 24px 36px;
  }

  .nav-links {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .hero-card h1 {
    font-size: 1.6rem;
  }

  .brand-title {
    font-size: 1.2rem;
  }

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

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-14px);
  }
  100% {
    transform: translateY(0px);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-orb,
  .spin-ring {
    animation: none;
  }
}
.bg-orb,
.spin-ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  filter: blur(0px);
  opacity: 0.55;
  background: radial-gradient(circle, rgba(246, 193, 119, 0.6) 0%, rgba(19, 111, 99, 0.05) 70%);
  animation: float 12s ease-in-out infinite;
}

[data-theme="dark"] .bg-orb {
  background: radial-gradient(circle, rgba(74, 212, 184, 0.35) 0%, rgba(19, 111, 99, 0.1) 70%);
}

.orb-1 {
  width: 220px;
  height: 220px;
  top: 140px;
  left: -60px;
}

.orb-2 {
  width: 180px;
  height: 180px;
  top: 120px;
  right: -60px;
  animation-delay: -4s;
}

.orb-3 {
  width: 140px;
  height: 140px;
  bottom: 120px;
  right: 80px;
  animation-delay: -7s;
}

.spin-ring {
  border: 2px dashed rgba(19, 111, 99, 0.4);
  animation: spin 18s linear infinite;
}

[data-theme="dark"] .spin-ring {
  border-color: rgba(74, 212, 184, 0.4);
}

.ring-1 {
  width: 140px;
  height: 140px;
  top: 360px;
  left: 60px;
}

.ring-2 {
  width: 110px;
  height: 110px;
  bottom: 80px;
  left: 180px;
  animation-direction: reverse;
}
[data-theme="dark"] .preview-image,
[data-theme="dark"] .preview-canvas {
  background: #0f1416;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  overflow: hidden;
  background: #f0ece6;
}

.preview-image,
.preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-image.is-empty {
  display: none;
}

.preview-canvas.is-empty {
  visibility: hidden;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 12px;
  border: 1px dashed var(--stroke);
}

[data-theme="dark"] .preview-placeholder {
  background: rgba(15, 20, 22, 0.9);
}
