/* ============================================
   고서 예역 시스템 — Classical Korean Scholarly Theme
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --ivory: #f5f0e8;
  --ivory-light: #faf7f2;
  --brown-dark: #3a2a1a;
  --brown-warm: #8b6914;
  --gold-muted: #c4a35a;
  --gold-light: #e8d9a8;
  --border-subtle: #d4c5a9;
  --border-light: #e6dcc8;
  --bg-sidebar: #2e2318;
  --bg-sidebar-hover: #3f3126;
  --red-muted: #a94442;
  --red-light: #f2dede;
  --green-muted: #3c763d;
  --green-light: #dff0d8;
  --blue-muted: #31708f;
  --blue-light: #d9edf7;
  --shadow-sm: 0 1px 3px rgba(58, 42, 26, 0.08);
  --shadow-md: 0 2px 8px rgba(58, 42, 26, 0.1);
  --shadow-lg: 0 4px 16px rgba(58, 42, 26, 0.12);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --font-serif: "Noto Serif KR", Georgia, "Times New Roman", serif;
  --font-sans: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --nav-height: 56px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--ivory);
  color: var(--brown-dark);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--brown-warm);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--gold-muted);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  color: var(--brown-dark);
  line-height: 1.3;
  font-weight: 600;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-wrapper {
  min-height: calc(100vh - var(--nav-height));
  padding-top: calc(var(--nav-height) + 24px);
  padding-bottom: 40px;
}

/* --- Header / Nav --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: linear-gradient(135deg, #2a1f14 0%, var(--brown-dark) 50%, #1e1610 100%);
  color: var(--ivory);
  display: flex;
  align-items: center;
  padding: 0;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}

.navbar-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.navbar-brand {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ivory);
  letter-spacing: 0.05em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-logo {
  height: 32px;
  width: auto;
  border-radius: 4px;
  object-fit: cover;
}

.brand-text {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-brand:hover {
  color: var(--gold-muted);
}

.navbar-brand:hover .brand-text {
  background: linear-gradient(135deg, #fff, var(--gold-light));
  -webkit-background-clip: text;
  background-clip: text;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  list-style: none;
}

.navbar-nav .nav-link {
  color: rgba(245, 240, 232, 0.75);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 400;
  transition: all var(--transition);
  position: relative;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  color: var(--gold-light);
  background: rgba(196, 163, 90, 0.12);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid rgba(196, 163, 90, 0.25);
  color: rgba(245, 240, 232, 0.7);
  font-size: 0.85rem;
}

.user-name-tag {
  color: var(--gold-light);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.user-name-tag:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.btn-logout {
  color: rgba(245, 240, 232, 0.6);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: all var(--transition);
}

.btn-logout:hover {
  color: #fff;
  background: rgba(169, 68, 66, 0.3);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gold-light);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* --- Hero Banner (Scroll-driven Video) --- */
.hero-banner {
  position: relative;
  width: 100%;
  height: 250vh;
  margin-top: var(--nav-height);
  background: #0a0806;
}

.banner-sticky {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.banner-sticky.scrubbing {
  cursor: grabbing;
}

.banner-sticky video {
  height: 65vh;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  border-radius: 14px;
  box-shadow: 0 4px 50px rgba(180,160,120,0.12), 0 0 80px rgba(0,0,0,0.35);
}

.banner-overlay {
  display: none;
}

.hero-text-block {
  position: relative;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.1s ease;
  flex-shrink: 0;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 2px 16px rgba(0,0,0,0.8);
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  letter-spacing: 0.06em;
  font-weight: 300;
}

/* Banner inline footer (login/register pages) */
.banner-footer {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(245, 240, 232, 0.4);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.banner-footer a {
  color: rgba(196, 163, 90, 0.55);
  text-decoration: none;
}

.banner-footer a:hover {
  color: var(--gold-light);
}

/* Hide the real footer on banner auth pages */
.hero-banner ~ .footer {
  display: none;
}

.scroll-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 10;
}

.scroll-arrow {
  display: inline-block;
  font-size: 1.3rem;
  animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(8px); opacity: 0.5; }
}

/* --- Main Content --- */
.main-content {
  padding-top: calc(var(--nav-height) + 24px);
  padding-bottom: 40px;
  min-height: calc(100vh - var(--nav-height));
}

.hero-banner + .main-content {
  padding: 0;
  min-height: 0;
  height: 0;
  overflow: hidden;
}

/* --- Banner Auth Overlay --- */
.banner-auth-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0;
}

.banner-brand-img {
  height: 90px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  margin-top: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(196, 163, 90, 0.4)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.banner-auth-wrap .auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  background: rgba(22, 20, 16, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(196, 163, 90, 0.15);
  border-radius: 12px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5), 0 0 100px rgba(196, 163, 90, 0.03);
  padding: 40px 36px;
  margin-bottom: auto;
  flex-shrink: 1;
}

.banner-auth-wrap .auth-card::-webkit-scrollbar {
  width: 6px;
}
.banner-auth-wrap .auth-card::-webkit-scrollbar-track {
  background: transparent;
}
.banner-auth-wrap .auth-card::-webkit-scrollbar-thumb {
  background: rgba(196, 163, 90, 0.25);
  border-radius: 3px;
}
.banner-auth-wrap .auth-card::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 163, 90, 0.4);
}

.banner-auth-wrap .auth-card::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 240px;
  background: url('/static/images/고서_2.png') center/contain no-repeat;
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
}

.banner-auth-wrap .auth-card > * {
  position: relative;
  z-index: 1;
}

.banner-auth-wrap .auth-card-header {
  text-align: center;
  margin-bottom: 32px;
}

.banner-auth-wrap .auth-card h2 {
  font-family: var(--font-serif);
  color: var(--gold-light);
  font-size: 1.6rem;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.banner-auth-wrap .auth-card .auth-subtitle {
  color: rgba(245, 240, 232, 0.5);
  font-size: 0.9rem;
}

.banner-auth-wrap .auth-card label {
  color: rgba(245, 240, 232, 0.75);
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.banner-auth-wrap .auth-card .form-group {
  margin-bottom: 22px;
}

.banner-auth-wrap .auth-card .form-control {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  border-bottom: 2px solid rgba(196, 163, 90, 0.2);
  color: var(--ivory-light);
  padding: 12px 4px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s ease;
}

.banner-auth-wrap .auth-card .form-control:focus {
  border-bottom-color: var(--gold-muted);
  background: rgba(255, 255, 255, 0.07);
}

.banner-auth-wrap .auth-card .form-control::placeholder {
  color: rgba(168, 155, 133, 0.4);
}

.banner-auth-wrap .auth-card .btn-primary {
  background: linear-gradient(135deg, var(--gold-muted), var(--brown-warm));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 24px rgba(196, 163, 90, 0.15);
  border: none;
  padding: 13px 24px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.95rem;
  width: 100%;
  display: flex;
  justify-content: center;
  transition: all 0.2s ease;
}

.banner-auth-wrap .auth-card .btn-primary:hover {
  background: linear-gradient(135deg, #d4b36a, #a07a18);
  box-shadow: 0 4px 30px rgba(196, 163, 90, 0.3);
  transform: translateY(-1px);
}

.banner-auth-wrap .auth-card .form-hint {
  color: rgba(168, 155, 133, 0.6);
  font-size: 0.8rem;
}

.banner-auth-wrap .auth-card .hint-success { color: #6cb86c; }
.banner-auth-wrap .auth-card .hint-error { color: #e88; }

.banner-auth-wrap .auth-card .alert { border-radius: 4px; }
.banner-auth-wrap .auth-card .alert-error {
  background: rgba(169, 68, 66, 0.15);
  border-color: rgba(169, 68, 66, 0.3);
  color: #f0a0a0;
}
.banner-auth-wrap .auth-card .alert-success {
  background: rgba(60, 118, 61, 0.15);
  border-color: rgba(60, 118, 61, 0.3);
  color: #9fd99f;
}

.banner-auth-wrap .auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: rgba(245, 240, 232, 0.45);
}

.banner-auth-wrap .auth-footer a { color: var(--gold-muted); }
.banner-auth-wrap .auth-footer a:hover { color: var(--gold-light); }

.banner-auth-wrap .remember-row {
  display: flex;
  align-items: center;
  margin-top: -4px;
  margin-bottom: 20px;
}

.banner-auth-wrap .remember-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: rgba(245, 240, 232, 0.55);
}

.banner-auth-wrap .remember-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-muted);
  cursor: pointer;
}

.banner-auth-wrap .auth-card-wide {
  max-width: 440px;
}

.banner-auth-wrap .auth-card-wide .auth-card-header {
  margin-bottom: 20px;
}

.banner-auth-wrap .auth-card-wide h2 {
  font-size: 1.35rem;
}

.banner-auth-wrap .auth-card-wide .auth-subtitle {
  font-size: 0.82rem;
}

.banner-auth-wrap .auth-card-wide .form-group {
  margin-bottom: 14px;
}

.banner-auth-wrap .auth-card-wide label {
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.banner-auth-wrap .auth-card-wide .form-control {
  padding: 9px 4px;
  font-size: 0.88rem;
}

.banner-auth-wrap .auth-card-wide .form-hint {
  font-size: 0.72rem;
}

.banner-auth-wrap .auth-card-wide .btn-primary {
  padding: 11px 20px;
  font-size: 0.88rem;
}

.banner-auth-wrap .auth-card-wide .auth-footer {
  margin-top: 14px;
  font-size: 0.8rem;
}

.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -4px;
  margin-bottom: 20px;
}

.remember-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #8a7e6a;
}

.remember-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-muted);
  cursor: pointer;
}

/* --- Auth Pages --- */
.auth-card-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  width: 200px;
  height: auto;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

/* --- Footer --- */
.footer {
  background: linear-gradient(135deg, #2a1f14, var(--brown-dark));
  color: rgba(245, 240, 232, 0.6);
  padding: 24px;
  text-align: center;
  font-size: 0.85rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-logo {
  height: 36px;
  width: auto;
  border-radius: 4px;
  opacity: 0.7;
}

.footer a {
  color: var(--gold-muted);
}

.footer a:hover {
  color: var(--gold-light);
}

/* --- Responsive Banner --- */
@media (max-width: 768px) {
  .hero-banner {
    height: 120vh;
  }
  .banner-sticky video {
    height: 55vh;
  }
  .hero-title {
    font-size: 1.4rem;
  }
  .hero-subtitle {
    font-size: 0.82rem;
  }
  .banner-auth-wrap .auth-card {
    padding: 28px 22px;
  }
  .banner-brand-img {
    height: 64px;
    margin-bottom: 8px;
  }
}

/* --- Cards --- */
.card {
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--brown-dark);
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.card-body {
  font-size: 0.95rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--brown-dark);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 10px 4px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-subtle);
  border-radius: 0;
  outline: none;
  transition: border-color var(--transition);
}

.form-control:focus {
  border-bottom-color: var(--gold-muted);
}

.form-control::placeholder {
  color: #a89b85;
}

.form-control-box {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control-box:focus {
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.15);
}

.form-hint {
  font-size: 0.8rem;
  color: #8a7e6a;
  margin-top: 4px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brown-warm);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #a07a18;
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--border-subtle);
  color: var(--brown-dark);
}

.btn-secondary:hover:not(:disabled) {
  background: #c4b594;
}

.btn-danger {
  background: var(--red-muted);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #8b3636;
}

.btn-copy {
  background: transparent;
  color: var(--brown-warm);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-copy:hover:not(:disabled) {
  background: var(--border-light);
  border-color: var(--gold-muted);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--brown-warm);
  color: var(--brown-warm);
}

.btn-outline:hover:not(:disabled) {
  background: var(--brown-warm);
  color: #fff;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

thead th {
  background: var(--brown-dark);
  color: var(--ivory);
  font-weight: 500;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr {
  background: var(--ivory-light);
  transition: background var(--transition);
}

tbody tr:nth-child(even) {
  background: var(--ivory);
}

tbody tr:hover {
  background: var(--gold-light);
}

tbody tr.selected {
  background: #e8dbb8;
}

table .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- Login / Register --- */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height) - 80px);
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.auth-card h2 {
  font-family: var(--font-serif);
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.5rem;
}

.auth-card .auth-subtitle {
  text-align: center;
  color: #8a7e6a;
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-card .form-group {
  margin-bottom: 22px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: #8a7e6a;
}

/* --- Translation Page --- */
.translate-controls {
  background: var(--ivory-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.translate-controls .control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.translate-controls .control-group label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #6b5e4d;
}

.prompt-section {
  margin-bottom: 20px;
}

.prompt-section .prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.prompt-section .prompt-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.output-section {
  margin-bottom: 20px;
}

.output-section .output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.output-section .output-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.output-box {
  width: 100%;
  min-height: 200px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
  max-height: 400px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.button-row-spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #6b5e4d;
  padding: 6px 14px;
  background: var(--ivory);
  border: 1px solid var(--border-light);
  border-radius: 20px;
}

.status-indicator .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-subtle);
}

.status-indicator.active .status-dot {
  background: var(--gold-muted);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.status-indicator.complete .status-dot {
  background: var(--green-muted);
}

.status-indicator.error .status-dot {
  background: var(--red-muted);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.usage-info {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #6b5e4d;
  padding: 10px 0;
}

.usage-info span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.usage-info strong {
  color: var(--brown-dark);
}

/* --- Admin Layout --- */
.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--nav-height) - 80px);
  gap: 0;
  margin-top: var(--nav-height);
}

.admin-sidebar {
  width: 240px;
  background: linear-gradient(180deg, #2a1f14, #1e1610);
  padding: 24px 0;
  flex-shrink: 0;
  border-right: 1px solid rgba(196, 163, 90, 0.1);
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
}

.admin-sidebar-title {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  padding: 0 20px 16px;
  color: rgba(245, 240, 232, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: rgba(245, 240, 232, 0.75);
  font-size: 0.9rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.admin-sidebar nav a:hover {
  background: var(--bg-sidebar-hover);
  color: var(--ivory);
}

.admin-sidebar nav a.active {
  background: var(--bg-sidebar-hover);
  color: var(--gold-muted);
  border-left-color: var(--gold-muted);
}

.admin-content {
  padding: 28px 32px;
  overflow-y: auto;
}

.admin-section {
  background: var(--ivory-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-section h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--brown-dark);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.admin-section .section-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

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

.admin-stat-card {
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}

.admin-stat-card .stat-value {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brown-warm);
}

.admin-stat-card .stat-label {
  font-size: 0.82rem;
  color: #8a7e6a;
  margin-top: 4px;
}

/* --- Messages / Alerts --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--green-light);
  color: var(--green-muted);
  border-color: #c3e6cb;
}

.alert-error {
  background: var(--red-light);
  color: var(--red-muted);
  border-color: #ebccd1;
}

.alert-info {
  background: var(--blue-light);
  color: var(--blue-muted);
  border-color: #bce8f1;
}

.alert-warning {
  background: #fcf8e3;
  color: #8a6d3b;
  border-color: #faebcc;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 12px);
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: #fff;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  max-width: 360px;
}

.toast-success {
  background: var(--green-muted);
}

.toast-error {
  background: var(--red-muted);
}

.toast-info {
  background: var(--blue-muted);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* --- Modal / Dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(46, 35, 24, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--ivory-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
  max-width: 440px;
  width: 90%;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h3 {
  font-family: var(--font-serif);
  margin-bottom: 12px;
  font-size: 1.15rem;
}

.modal p {
  font-size: 0.92rem;
  color: #5a4d3a;
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Responsive --- */
@media (max-width: 992px) {
  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    position: static;
    height: auto;
    padding: 16px 0;
    border-right: none;
  }

  .admin-sidebar nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0 12px;
    gap: 4px;
  }

  .admin-sidebar nav a {
    padding: 8px 14px;
    border-left: none;
    border-radius: var(--radius-sm);
  }

  .admin-content {
    padding: 20px 16px;
  }
}

@media (max-width: 768px) {
  :root {
    --nav-height: 52px;
  }

  .navbar {
    padding: 0;
  }

  .navbar-inner {
    padding: 0 12px;
    flex-wrap: nowrap;
  }

  .navbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    order: -1;
    margin-right: 8px;
    flex-shrink: 0;
  }

  .navbar-brand {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 1.1rem;
    gap: 6px;
  }

  .brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .navbar-logo {
    height: 26px;
    flex-shrink: 0;
  }

  .navbar-nav {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--brown-dark);
    flex-direction: column;
    padding: 8px 16px 16px;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  .navbar-nav.open {
    display: flex;
  }

  .navbar-nav a {
    padding: 10px 14px;
  }

  .navbar-nav.navbar-nav--auth {
    display: flex;
    position: static;
    flex-direction: row;
    background: none;
    padding: 0;
    margin-left: auto;
    box-shadow: none;
    gap: 6px;
  }

  .navbar-nav--auth .nav-link {
    padding: 6px 12px !important;
    font-size: 0.78rem !important;
    border: 1px solid rgba(196, 163, 90, 0.35);
    border-radius: 6px;
    color: var(--gold-light) !important;
    white-space: nowrap;
  }

  .navbar-nav--auth .nav-link:hover,
  .navbar-nav--auth .nav-link.active {
    background: rgba(196, 163, 90, 0.15) !important;
  }

  .navbar-user {
    border-left: none;
    padding-left: 0;
    margin-left: auto;
    padding-top: 0;
    border-top: none;
    white-space: nowrap;
    flex-shrink: 0;
    gap: 8px;
    font-size: 0.8rem;
  }

  .container {
    padding: 0 14px;
  }

  .auth-card {
    padding: 28px 22px;
  }

  .translate-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .button-row,
  .button-row-spread {
    flex-direction: column;
  }

  .button-row .btn,
  .button-row-spread .btn {
    width: 100%;
  }

  table {
    font-size: 0.82rem;
  }

  thead th, tbody td {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .navbar-inner {
    padding: 0 8px;
  }

  .navbar-brand {
    font-size: 1rem;
    gap: 5px;
  }

  .navbar-logo {
    height: 22px;
  }

  .user-name-tag {
    display: inline-block;
    max-width: 5em;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
  }

  .navbar-user {
    gap: 6px;
    font-size: 0.75rem;
  }

  .btn-logout {
    padding: 3px 6px;
    font-size: 0.72rem;
  }

  .navbar-nav--auth .nav-link {
    padding: 5px 8px !important;
    font-size: 0.72rem !important;
  }

  .card {
    padding: 18px 16px;
  }

  .admin-section {
    padding: 18px 14px;
  }

  .usage-info {
    flex-direction: column;
    gap: 8px;
  }

  .banner-auth-wrap .auth-card {
    padding: 24px 18px;
    margin-left: 8px;
    margin-right: 8px;
  }

  .banner-auth-wrap .auth-card-wide {
    padding: 20px 16px;
  }

  .banner-brand-img {
    height: 52px;
    margin-bottom: 6px;
  }

  .banner-auth-wrap .auth-card h2 {
    font-size: 1.3rem;
  }

  .banner-auth-wrap .auth-card-wide h2 {
    font-size: 1.15rem;
  }

  .banner-auth-wrap .auth-card-wide .form-group {
    margin-bottom: 10px;
  }

  .banner-auth-wrap .auth-card-wide .form-control {
    padding: 7px 4px;
    font-size: 0.82rem;
  }

  .banner-auth-wrap .auth-card-wide .btn-primary {
    padding: 10px 16px;
    font-size: 0.82rem;
  }
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: #8a7e6a; }
.text-small { font-size: 0.85rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mr-1 { margin-right: 8px; }
.ml-1 { margin-left: 8px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.w-100 { width: 100%; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Loading / Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--gold-muted);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(245, 240, 232, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #8a7e6a;
  font-size: 0.88rem;
}

/* --- Scrollbar --- */
textarea::-webkit-scrollbar,
.output-box::-webkit-scrollbar {
  width: 8px;
}

textarea::-webkit-scrollbar-track,
.output-box::-webkit-scrollbar-track {
  background: var(--ivory);
  border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb,
.output-box::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb:hover,
.output-box::-webkit-scrollbar-thumb:hover {
  background: var(--gold-muted);
}

/* --- Radio Buttons (Generation Mode) --- */
.radio-group {
  display: flex;
  gap: 4px;
  background: var(--ivory);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.radio-group input[type="radio"] {
  display: none;
}

.radio-group label {
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b5e4d;
  cursor: pointer;
  border-radius: 3px;
  transition: all var(--transition);
  text-align: center;
}

.radio-group input[type="radio"]:checked + label {
  background: var(--brown-warm);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.radio-group label:hover {
  background: var(--border-light);
}

.radio-group input[type="radio"]:checked + label:hover {
  background: var(--brown-warm);
}

/* --- Range Slider --- */
.range-slider {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  outline: none;
  transition: background var(--transition);
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brown-warm);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition);
}

.range-slider input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-slider input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brown-warm);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.range-slider .range-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--brown-dark);
  min-width: 28px;
  text-align: center;
}

/* --- Textarea --- */
textarea {
  width: 100%;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea:focus {
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.12);
}

textarea.large {
  min-height: 200px;
}

textarea[readonly] {
  background: var(--ivory);
  cursor: default;
}

/* old footer overridden by new footer above */

/* --- Dropdown / Select --- */
select {
  padding: 8px 32px 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%233a2a1a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus {
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.15);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Badge --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.badge-pending {
  background: #fcf8e3;
  color: #8a6d3b;
}

.badge-active {
  background: var(--green-light);
  color: var(--green-muted);
}

.badge-inactive {
  background: var(--red-light);
  color: var(--red-muted);
}

/* --- Tabs (for admin sections) --- */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border-subtle);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
}

.tab-nav button {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  color: #8a7e6a;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-nav button:hover {
  color: var(--brown-dark);
}

.tab-nav button.active {
  color: var(--brown-warm);
  border-bottom-color: var(--brown-warm);
  font-weight: 500;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- File upload area --- */
.file-upload {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.file-upload:hover {
  border-color: var(--gold-muted);
  background: rgba(196, 163, 90, 0.05);
}

.file-upload input[type="file"] {
  display: none;
}

.file-upload .upload-label {
  font-size: 0.9rem;
  color: #6b5e4d;
}

.file-upload .upload-label strong {
  color: var(--brown-warm);
  cursor: pointer;
}

/* --- Preview box --- */
.preview-box {
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-family: monospace;
  background: var(--ivory);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Checkbox styled --- */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brown-warm);
  cursor: pointer;
}

/* --- Transition helpers --- */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   Template-specific supplemental styles
   ============================================ */

/* --- Auth Pages (login.html, register.html) --- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height) - 80px);
  padding: 40px 20px;
  padding-top: calc(var(--nav-height) + 40px);
}

.auth-card-wide {
  max-width: 520px;
}

.hint-success {
  color: var(--green-muted);
}

.hint-error {
  color: var(--red-muted);
}

/* --- Translate Page --- */
.translate-container {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 24px) 20px 40px;
}

.translate-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.user-info {
  font-size: 0.9rem;
  color: var(--brown-dark);
}

.user-label {
  font-weight: 500;
}

.control-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group-full {
  flex: 1;
  min-width: 200px;
}

.control-group-btn {
  display: flex;
  align-items: flex-end;
}

.control-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #6b5e4d;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b5e4d;
  cursor: pointer;
  border-radius: 3px;
  transition: all var(--transition);
  text-align: center;
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-group .radio-label:has(input:checked) {
  background: var(--brown-warm);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.radio-group .radio-label:has(input:checked):hover {
  background: var(--brown-warm);
}

.translate-input,
.translate-output {
  margin-bottom: 24px;
}

.section-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--brown-dark);
  letter-spacing: 0.01em;
}

.textarea-main,
.textarea-output {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.7;
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--brown-dark);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.textarea-main:focus,
.textarea-output:focus {
  outline: none;
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.12);
}

.textarea-main {
  min-height: 200px;
}

.textarea-output {
  background: var(--ivory);
}

.output-block {
  background: var(--ivory-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}

.output-block .output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.output-block .section-label {
  margin-bottom: 0;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(196, 163, 90, 0.06);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.status-label {
  font-weight: 500;
  color: #6b5e4d;
}

.status-text {
  color: var(--brown-warm);
  font-weight: 500;
}

.translate-footer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  gap: 12px;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--red-muted);
  color: var(--red-muted);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--red-muted);
  color: #fff;
}

.copy-btn {
  background: transparent;
  color: var(--brown-warm);
  border: 1px solid var(--border-subtle);
}

.copy-btn:hover:not(:disabled) {
  background: var(--border-light);
  border-color: var(--gold-muted);
}

/* --- Form elements used in templates --- */
.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  border-color: var(--gold-muted);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.15);
}

.form-input[readonly] {
  background: var(--ivory);
  cursor: default;
}

.form-input-file {
  padding: 8px;
  font-size: 0.9rem;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 150px;
}

.form-select {
  width: 100%;
}

.form-select-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.form-card {
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

/* --- Admin Page — Sidebar (uses .admin-sidebar from base) --- */
.sidebar-title {
  color: var(--gold-light);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0 20px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(196, 163, 90, 0.12);
  letter-spacing: 0.05em;
}

.sidebar-nav ul {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.sidebar-link {
  display: block;
  padding: 10px 20px;
  color: rgba(245, 240, 232, 0.7);
  font-size: 0.88rem;
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  color: var(--gold-light);
  background: rgba(196, 163, 90, 0.06);
  border-left-color: rgba(196, 163, 90, 0.3);
}

.sidebar-link.active {
  color: var(--gold-light);
  background: rgba(196, 163, 90, 0.1);
  border-left-color: var(--gold-muted);
  font-weight: 500;
}

/* --- Admin Page — Main content area --- */
.admin-main {
  flex: 1;
  padding: 32px;
  min-width: 0;
  overflow-y: auto;
}

.admin-page-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--brown-dark);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-light);
}

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

.section-header h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* --- Dashboard Cards --- */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dashboard-card {
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.dashboard-card:hover {
  box-shadow: var(--shadow-md);
}

.card-icon {
  font-size: 2rem;
  line-height: 1;
}

.card-body {
  flex: 1;
}

.card-stat-label {
  font-size: 0.82rem;
  color: #8a7e6a;
  margin-bottom: 4px;
  font-weight: 400;
}

.card-stat-value {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brown-warm);
}

.dashboard-section {
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.dashboard-section h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: 16px;
}

/* --- Table elements used in admin templates --- */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead th {
  background: linear-gradient(135deg, #2a1f14, var(--brown-dark));
  color: var(--gold-light);
  padding: 12px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: rgba(196, 163, 90, 0.04);
}

.table-empty {
  text-align: center;
  padding: 40px 20px !important;
  color: #8a7e6a;
}

.table-error {
  color: var(--red-muted);
}

.action-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.row-selected {
  background: #e8dbb8 !important;
}

.badge-perm {
  background: var(--blue-light);
  color: var(--blue-muted);
}

/* --- Hanja Page --- */
.hanja-manager {
  margin-bottom: 8px;
}

.hanja-preview {
  margin-top: 12px;
}

.settings-display {
  background: var(--ivory);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-label {
  font-weight: 500;
  color: #6b5e4d;
  min-width: 160px;
  font-size: 0.9rem;
}

.setting-value {
  color: var(--brown-dark);
  font-size: 0.9rem;
}

/* --- Summary Cards (translation_data page) --- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: box-shadow 0.2s ease;
}

.summary-card:hover {
  box-shadow: var(--shadow-md);
}

.summary-label {
  display: block;
  font-size: 0.82rem;
  color: #8a7e6a;
  margin-bottom: 8px;
}

.summary-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brown-warm);
}

/* --- Filter & Section Actions --- */
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group .control-label {
  white-space: nowrap;
}

.section-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* --- Cell truncation --- */
.cell-text {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Checkbox group --- */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* --- Responsive supplements for new classes --- */
@media (max-width: 992px) {
  .sidebar-nav ul {
    display: flex;
    flex-wrap: wrap;
    padding: 0 12px;
    gap: 4px;
  }

  .sidebar-link {
    padding: 8px 14px;
    border-left: none;
    border-radius: var(--radius-sm);
  }

  .admin-main {
    padding: 20px 16px;
  }
}

@media (max-width: 768px) {
  .translate-container {
    padding-top: calc(var(--nav-height) + 16px);
    padding-left: 14px;
    padding-right: 14px;
  }

  .translate-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-container {
    padding-top: calc(var(--nav-height) + 20px);
    padding-left: 14px;
    padding-right: 14px;
  }

  .form-row {
    flex-direction: column;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .section-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* --- Print styles --- */
@media print {
  .navbar, .admin-sidebar, .btn, .button-row, .toast-container {
    display: none !important;
  }

  .page-wrapper {
    padding-top: 0;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* === History Page === */
.history-container {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 24px) 20px 40px;
}

.history-header {
  margin-bottom: 24px;
}

.history-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--brown-dark);
  margin-bottom: 6px;
}

.history-desc {
  color: #7a6e5c;
  font-size: 0.9rem;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.search-box {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 500px;
}

.search-box .form-control-box {
  flex: 1;
}

.history-stats {
  font-size: 0.85rem;
  color: #7a6e5c;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}

.history-loading,
.history-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #8a7e6a;
  font-size: 0.95rem;
}

.history-card {
  background: var(--ivory-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.history-card:hover {
  border-color: var(--gold-muted);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.history-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history-date {
  font-size: 0.82rem;
  color: #7a6e5c;
  font-family: var(--font-sans);
}

.history-mode-badge {
  font-size: 0.75rem;
  background: var(--brown-dark);
  color: var(--gold-light);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.history-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.history-input-preview,
.history-output-preview {
  display: flex;
  gap: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.preview-label {
  flex-shrink: 0;
  width: 36px;
  font-weight: 600;
  color: var(--brown-warm);
  font-size: 0.78rem;
  padding-top: 2px;
}

.preview-text {
  color: var(--brown-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-output-preview .preview-text {
  color: #5a4d3c;
}

.history-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Pagination */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  background: var(--ivory-light);
  color: var(--brown-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.page-btn:hover:not(.disabled):not(.active) {
  background: var(--gold-light);
  border-color: var(--gold-muted);
}

.page-btn.active {
  background: var(--brown-warm);
  color: #fff;
  border-color: var(--brown-warm);
  font-weight: 600;
}

.page-btn.disabled {
  opacity: 0.4;
  cursor: default;
}

.page-dots {
  color: #8a7e6a;
  padding: 0 4px;
  line-height: 36px;
}

/* History Modal */
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.history-modal.open {
  opacity: 1;
}

.history-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.history-modal-content {
  position: relative;
  background: var(--ivory-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.history-modal.open .history-modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  margin: 0;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #8a7e6a;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}

.btn-close-modal:hover {
  color: var(--brown-dark);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b5e4d;
  margin-bottom: 6px;
}

.detail-label-with-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.detail-label-with-btn span {
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b5e4d;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--brown-dark);
}

.detail-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  color: var(--brown-dark);
  background: var(--ivory);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  resize: vertical;
  line-height: 1.6;
}

.detail-pre {
  background: var(--ivory);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
  color: #5a4d3c;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

@media (max-width: 768px) {
  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: none;
  }
  .history-card-actions {
    flex-wrap: wrap;
  }
  .history-modal-content {
    width: 95%;
    max-height: 95vh;
  }
}
