:root {
  --bg-1: #0f172a;
  --bg-2: #1e293b;
  --body-text: #f8fafc;
  --subtitle: #cbd5e1;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.15);
  --field-bg: rgba(15, 23, 42, 0.75);
  --field-text: #e2e8f0;
  --reader-bg: rgba(2, 6, 23, 0.7);
  --reader-border: rgba(255, 255, 255, 0.3);
  --placeholder: #94a3b8;
  --footer-text: #cbd5e1;
  --footer-link: #7dd3fc;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 10% 10%, #1d4ed8 0%, transparent 35%),
              radial-gradient(circle at 80% 20%, #0369a1 0%, transparent 30%),
              linear-gradient(140deg, var(--bg-1), var(--bg-2));
  color: var(--body-text);
  position: relative;
  overflow-x: hidden;
}

body.theme-light {
  --bg-1: #f8fafc;
  --bg-2: #e2e8f0;
  --body-text: #0f172a;
  --subtitle: #334155;
  --card-bg: rgba(255, 255, 255, 0.86);
  --card-border: rgba(15, 23, 42, 0.12);
  --field-bg: #ffffff;
  --field-text: #0f172a;
  --reader-bg: #ffffff;
  --reader-border: rgba(15, 23, 42, 0.2);
  --placeholder: #64748b;
  --footer-text: #334155;
  --footer-link: #1d4ed8;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  z-index: -1;
}

.bg-shape-1 {
  width: 240px;
  height: 240px;
  background: rgba(245, 158, 11, 0.26);
  top: 12%;
  left: -60px;
}

.bg-shape-2 {
  width: 280px;
  height: 280px;
  background: rgba(56, 189, 248, 0.2);
  bottom: 8%;
  right: -80px;
}

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
}

.title-gradient {
  background: linear-gradient(90deg, var(--body-text) 20%, #f59e0b 60%, #0ea5e9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

body.theme-light .title-gradient {
  background: linear-gradient(90deg, #0f172a 10%, #b45309 55%, #0c4a6e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.content-box {
  background: var(--field-bg);
  color: var(--field-text);
  border: 1px solid var(--card-border);
}

.content-box:focus {
  background: var(--field-bg);
  color: var(--field-text);
}

.control-chip {
  border-radius: 0.75rem;
  background: var(--field-bg);
  border: 1px solid var(--card-border);
}

.control-chip .form-label,
#speedDisplay {
  color: var(--body-text) !important;
}

.glass-card .form-label,
.glass-card .h4,
.glass-card h2 {
  color: var(--body-text) !important;
}

.form-check-label {
  color: var(--body-text);
}

.shortcuts-chip .guide-list {
  color: var(--body-text);
  padding-left: 1rem;
}

.shortcuts-chip h3,
.shortcuts-chip .guide-list li,
.shortcuts-chip .guide-list strong {
  color: var(--body-text) !important;
}

.shortcuts-chip .guide-list li {
  margin-bottom: 0.2rem;
}

.reader-box {
  min-height: 250px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--reader-bg);
  border: 1px dashed var(--reader-border);
  border-radius: 1rem;
  padding: 1.1rem;
  line-height: 2.1;
  font-size: 1.1rem;
}

.reader-box:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  min-height: 100vh;
  margin: 0;
  border-radius: 0;
  border-style: solid;
  padding: 2rem;
  line-height: 2.3;
  font-size: 1.3rem;
  background: var(--reader-bg);
}

.word {
  display: inline-block;
  margin: 0 0.2rem 0.35rem 0;
  padding: 0.08rem 0.16rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.word.current {
  background: rgba(56, 189, 248, 0.3);
  color: var(--body-text);
  filter: none;
  opacity: 1;
  transform: translateY(-1px);
}

.word.read {
  transition: all 0.2s ease;
}

.word.read.read-effect-blur {
  color: color-mix(in oklab, var(--body-text), transparent 55%);
  filter: blur(1.8px);
}

.word.read.read-effect-hide {
  visibility: hidden;
}

.word.read.read-effect-fade {
  color: color-mix(in oklab, var(--body-text), transparent 72%);
  filter: none;
}

.word.unread {
  color: var(--body-text);
}

.word.stopword {
  filter: blur(1.7px);
  opacity: 0.55;
}

.placeholder-text {
  color: var(--placeholder);
}

.estimate-note {
  color: var(--subtitle);
}

.history-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 0.6rem;
  padding: 0.75rem;
  background: color-mix(in oklab, var(--reader-bg), transparent 15%);
}

.history-item {
  padding: 0.45rem 0.25rem;
  border-bottom: 1px dashed var(--card-border);
  color: var(--body-text);
  font-size: 0.92rem;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--body-text);
  font-size: 0.9rem;
}

.history-table th,
.history-table td {
  border-bottom: 1px dashed var(--card-border);
  padding: 0.45rem 0.35rem;
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  font-weight: 700;
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.reader-box:focus,
#resultCard:focus,
#historySection:focus {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.48);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.countdown-number {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 800;
  color: #f8fafc;
  background: linear-gradient(145deg, rgba(14, 165, 233, 0.95), rgba(15, 23, 42, 0.95));
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.45);
}

.subtitle {
  color: var(--subtitle);
}

.footer-note {
  color: var(--footer-text);
}

.footer-note a {
  color: var(--footer-link);
  text-decoration: none;
}

.footer-note a:hover {
  text-decoration: underline;
}

body.theme-light .btn-outline-light {
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.3);
}

body.theme-light .btn-outline-light:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

body.theme-light .text-secondary {
  color: #334155 !important;
}

body.theme-light .text-light-emphasis {
  color: #334155 !important;
}

body.theme-light .form-text {
  color: #475569 !important;
}

.celebration-card {
  background: linear-gradient(130deg, rgba(245, 158, 11, 0.2), rgba(56, 189, 248, 0.2));
  border: 1px solid rgba(245, 158, 11, 0.6);
  animation: popIn 0.55s ease;
}

.celebration-icon {
  font-size: 3rem;
  color: #fbbf24;
  animation: bounce 1.1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  .reader-box {
    min-height: 210px;
    max-height: 300px;
    font-size: 1rem;
    line-height: 1.9;
  }

  .reader-box:fullscreen {
    padding: 1rem;
    font-size: 1.05rem;
    line-height: 2;
  }
}
