:root {
  --tb-blue: #e30613;
  --tb-blue-dark: #c80410;
  --tb-gold: #d2a84a;
  --tb-red: #9c2f1a;
  --tb-green: #1f6b45;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1e2430;
  --muted: #5f6b7a;
  --border: #dbe2ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(210, 168, 74, 0.14), transparent 24%),
    linear-gradient(180deg, #f7f4ee 0%, var(--bg) 34%, #eef2f8 100%);
}

.container {
  width: min(1180px, 94vw);
  margin: 0 auto;
}

.topbar {
  background: linear-gradient(120deg, var(--tb-blue), var(--tb-blue-dark));
  color: #fff;
  border-bottom: 4px solid var(--tb-gold);
  padding: 0.95rem 0 0.72rem;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.topbar-brand {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-nav {
  display: flex;
  gap: 0.22rem;
  flex-wrap: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  padding: 0.42rem 0.52rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
  font-size: 0.82rem;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.nav-link.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: var(--tb-blue-dark);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.1rem, 1.7vw, 1.65rem);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.topbar p {
  margin: 0.18rem 0 0;
  color: #d8e4f3;
  font-size: 0.92rem;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 0.44rem 0.6rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
  font-size: 0.88rem;
}

.logout-link:hover {
  background: rgba(255, 255, 255, 0.22);
}

.main-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.2rem;
  row-gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: 0 8px 20px rgba(11, 47, 87, 0.08);
}

h2 {
  margin-top: 0;
  color: var(--tb-blue);
}

label {
  display: block;
  margin: 0.4rem 0;
  color: var(--muted);
  font-weight: 600;
}

select,
textarea,
button,
input {
  width: 100%;
  font: inherit;
}

select,
textarea,
input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  background: #fff;
}

textarea {
  min-height: 210px;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  background: var(--tb-blue);
  color: #fff;
  font-weight: 700;
}

button:hover {
  opacity: 0.94;
}

button.secondary {
  background: #6f7b8a;
}

button.accent {
  background: linear-gradient(120deg, var(--tb-gold), #b98622);
  color: #13243b;
}

.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  color: var(--muted);
}

.translator-assessment {
  min-height: 1.2rem;
  margin: 0 0 0.75rem;
  padding: 0;
  border-radius: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.translator-assessment.is-warning,
.translator-assessment.is-error {
  padding: 0.75rem 0.9rem;
  border: 1px solid transparent;
}

.translator-assessment.is-warning {
  background: #fff3d8;
  border-color: rgba(185, 134, 34, 0.35);
  color: #8a610d;
}

.translator-assessment.is-error {
  background: #fdebe8;
  border-color: rgba(156, 47, 26, 0.28);
  color: #9c2f1a;
}

.footer {
  padding: 1rem 0 2rem;
  color: var(--muted);
}

.version-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  min-width: 220px;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(11, 47, 87, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(11, 47, 87, 0.12);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.version-panel strong {
  color: var(--text);
}

.feedback-card {
  grid-column: 1 / span 2;
}

.correction-card {
  min-height: 60vh;
}

.correction-intro {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
}

.correction-intro p {
  margin: 0;
}

.correction-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.correction-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.correction-table th,
.correction-table td {
  padding: 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.correction-table th {
  background: #f8fafc;
  color: var(--tb-blue-dark);
}

.correction-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.correction-type-cell {
  width: 130px;
}

.correction-row-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.correction-type-select {
  min-width: 100px;
}

.correction-cell-box {
  display: grid;
  gap: 0.45rem;
}

.correction-textarea {
  min-height: 108px;
}

.is-word-row .correction-textarea {
  min-height: 52px;
}

.correction-translate-btn {
  width: auto;
  justify-self: start;
  min-width: 134px;
}

.correction-flag-cell {
  width: 160px;
}

.correction-flag-btn {
  background: #6f7b8a;
}

.correction-flag-btn.is-active {
  background: linear-gradient(120deg, var(--tb-gold), #b98622);
  color: #13243b;
}

.correction-row-status {
  display: block;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.correction-row-actions {
  margin-top: 0.9rem;
}

.correction-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 0.9rem;
  margin-top: 1rem;
}

.correction-submit-bar {
  margin-top: 1rem;
}

.correction-submit-btn {
  width: auto;
  min-width: 220px;
}

.correction-status {
  margin-top: 0.9rem;
}

.dictionary-layout {
  margin-top: 1rem;
}

.dictionary-card {
  min-height: 60vh;
}

.dictionary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dictionary-intro {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.dictionary-count {
  min-width: 120px;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  background: #f7f0e1;
  border: 1px solid rgba(210, 168, 74, 0.35);
  text-align: center;
  color: var(--muted);
}

.dictionary-count strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.35rem;
  color: var(--tb-blue-dark);
}

.dictionary-search-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.phrases-search-row {
  margin-bottom: 1rem;
}

.phrases-list {
  display: grid;
  gap: 0.85rem;
}

.phrase-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(11, 47, 87, 0.05);
}

.phrase-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.1rem;
  background: linear-gradient(120deg, rgba(227, 6, 19, 0.08), rgba(196, 4, 16, 0.03));
  color: var(--text);
  text-align: left;
}

.phrase-trigger:hover {
  background: linear-gradient(120deg, rgba(227, 6, 19, 0.14), rgba(196, 4, 16, 0.06));
  opacity: 1;
}

.phrase-dialect {
  font-weight: 700;
  color: var(--tb-blue-dark);
}

.phrase-hint {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.phrase-meaning {
  padding: 0.95rem 1.1rem 1.05rem;
  color: var(--text);
  background: #fffaf3;
  border-top: 1px solid rgba(210, 168, 74, 0.28);
}

.phrase-meanings-list {
  margin: 0.45rem 0 0;
  padding-left: 1.2rem;
}

.phrase-meanings-list li + li {
  margin-top: 0.35rem;
}

.dictionary-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.dictionary-table {
  width: 100%;
  border-collapse: collapse;
}

.dictionary-table th,
.dictionary-table td {
  padding: 0.85rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.dictionary-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--tb-blue-dark);
  z-index: 1;
}

.dictionary-sort-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.dictionary-sort-buttons {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.dictionary-sort-button {
  width: auto;
  min-width: 58px;
  padding: 0.38rem 0.52rem;
  border-radius: 999px;
  background: #e7edf7;
  color: var(--tb-blue-dark);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.dictionary-sort-button:hover {
  background: #d7e2f1;
  opacity: 1;
}

.dictionary-sort-button.is-active {
  background: linear-gradient(120deg, var(--tb-gold), #b98622);
  color: #13243b;
}

.dictionary-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.dictionary-empty {
  text-align: center;
  color: var(--muted);
  padding: 1.4rem 1rem;
 }

.feedback-intro {
  margin-top: 0;
  color: var(--muted);
}

.notes-textarea {
  min-height: 110px;
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 0.4rem;
}

.feedback-status {
  min-height: 1.2rem;
  margin: 0.8rem 0 0;
  font-weight: 700;
}

.feedback-status.is-success {
  color: var(--tb-green);
}

.feedback-status.is-error {
  color: var(--tb-red);
}

.feature-intro-card,
.feature-section-card,
.hint-card,
.story-card {
  margin-bottom: 1rem;
}

.feature-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.category-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  padding: 1rem;
  border: 1px solid rgba(210, 168, 74, 0.35);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff8ec 0%, #ffffff 100%);
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 20px rgba(11, 47, 87, 0.06);
}

.category-card:hover {
  opacity: 1;
  background: linear-gradient(180deg, #fff1d2 0%, #ffffff 100%);
}

.category-card-link {
  text-decoration: none;
}

.category-card-static {
  cursor: default;
}

.category-card-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--tb-blue-dark);
}

.category-card-meta {
  color: var(--tb-red);
  font-weight: 700;
  font-size: 0.92rem;
}

.category-card-text {
  color: var(--muted);
  line-height: 1.45;
}

.feature-sections {
  display: grid;
  gap: 0.9rem;
}

.feature-details {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.feature-details summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  cursor: pointer;
  list-style: none;
  background: linear-gradient(120deg, rgba(227, 6, 19, 0.08), rgba(196, 4, 16, 0.03));
  color: var(--tb-blue-dark);
  font-weight: 700;
}

.feature-details summary::-webkit-details-marker {
  display: none;
}

.feature-summary-meta {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.feature-details-body {
  padding: 1rem 1.1rem 1.15rem;
}

.feature-lead {
  margin-top: 0;
  color: var(--muted);
}

.feature-block-grid,
.hint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem;
}

.feature-mini-card {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(210, 168, 74, 0.28);
  border-radius: 16px;
  background: #fffaf3;
}

.feature-mini-card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--tb-blue-dark);
}

.feature-word-grid {
  display: grid;
  gap: 0.7rem;
}

.feature-word-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px dashed rgba(95, 107, 122, 0.26);
}

.feature-word-item strong {
  color: var(--text);
}

.feature-word-item span {
  color: var(--tb-blue-dark);
  font-weight: 700;
}

.learn-phrase-list {
  display: grid;
  gap: 0.8rem;
}

.learn-phrase-item strong {
  display: block;
  color: var(--tb-blue-dark);
  margin-bottom: 0.35rem;
}

.learn-phrase-item ul,
.example-list,
.note-list {
  margin: 0;
  padding-left: 1.15rem;
}

.learn-phrase-item li + li,
.example-list li + li,
.note-list li + li {
  margin-top: 0.32rem;
}

.learn-text-list {
  display: grid;
  gap: 0.8rem;
}

.learn-text-item strong {
  display: block;
  color: var(--tb-blue-dark);
  margin-bottom: 0.35rem;
}

.learn-text-quote {
  margin: 0 0 0.4rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: #f7f0e1;
  color: var(--text);
  font-family: "Source Serif 4", Georgia, serif;
  line-height: 1.55;
}

.learn-text-gloss {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.feature-tip {
  margin-bottom: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: #f3f7fb;
  color: var(--muted);
}

.essay-card p {
  margin-top: 0;
  line-height: 1.7;
}

.essay-card p + p {
  margin-top: 0.95rem;
}

.essay-list {
  margin: 0;
  padding-left: 1.25rem;
}

.essay-list li + li {
  margin-top: 0.8rem;
}

.essay-list p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.story-controls {
  margin-bottom: 0.9rem;
}

.story-pairs {
  display: grid;
  gap: 0.85rem;
}

.story-pair {
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.story-pair-head {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.story-pair-index {
  min-width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f7f0e1;
  color: var(--tb-blue-dark);
  font-weight: 700;
}

.story-dialect {
  margin: 0;
  color: var(--tb-blue-dark);
  font-weight: 700;
  line-height: 1.55;
}

.story-toggle-one,
.story-toggle-all {
  width: auto;
  margin-top: 0.75rem;
}

.story-source {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(95, 107, 122, 0.3);
  color: var(--muted);
  line-height: 1.55;
}

.poem-text {
  margin: 0;
  padding: 1rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(210, 168, 74, 0.22);
  color: var(--text);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.poem-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.1rem;
  background: linear-gradient(120deg, rgba(227, 6, 19, 0.08), rgba(196, 4, 16, 0.03));
  color: var(--text);
  text-align: left;
}

.poem-toggle:hover {
  background: linear-gradient(120deg, rgba(227, 6, 19, 0.14), rgba(196, 4, 16, 0.06));
  opacity: 1;
}

.poem-toggle-title {
  font-weight: 700;
  color: var(--tb-blue-dark);
}

.poem-toggle-hint {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.poem-body {
  border-top: 1px solid rgba(210, 168, 74, 0.28);
  background: #fffaf3;
}

@media (max-width: 720px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .nav-link {
    flex: 1 1 0;
  }

  .main-layout {
    grid-template-columns: 1fr;
  }

  .feedback-card {
    grid-column: auto;
  }

  .logout-link {
    width: 100%;
  }

  .dictionary-header,
  .dictionary-search-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .dictionary-sort-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .correction-form-grid {
    grid-template-columns: 1fr;
  }

  .feature-section-header,
  .feature-details summary,
  .feature-word-item,
  .story-pair-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .version-panel {
    left: 12px;
    right: 12px;
    min-width: 0;
  }
}
