:root {
  --bg: #F6FAF2;
  --panel: #FFFFFF;
  --panel-hi: #EEF6E8;
  --line: #E1EBD9;
  --line-strong: #C9DABB;
  --ink: #1E2B1E;
  --muted: #6E7C68;
  --leaf: #2E8B45;
  --leaf-dark: #1E6B34;
  --leaf-tint: rgba(46, 139, 69, 0.12);
  --gold: #EFB92E;
  --gold-tint: rgba(239, 185, 46, 0.16);
  --good: #2E8B45;
  --bad: #D14343;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.app {
  display: flex;
  min-height: 100vh;
  opacity: 0;
  animation: rise 0.5s ease forwards;
}

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 28px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  object-fit: contain;
}

.brand-mark {
  font-family: 'Source Serif 4', serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--leaf-dark);
}

.brand-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
}

.year-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  flex: 1;
  overflow-y: auto;
}

.year-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.year-item:hover {
  background: var(--panel-hi);
  color: var(--ink);
}

.year-item.active {
  background: var(--gold-tint);
  color: var(--leaf-dark);
}

.year-num {
  font-family: 'Source Serif 4', serif;
  font-size: 19px;
  font-weight: 600;
}

.year-count {
  font-size: 12px;
  color: inherit;
  opacity: 0.75;
}

.sidebar-foot {
  padding: 16px 24px 0;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.admin-toggle {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.admin-toggle:hover {
  border-color: var(--leaf);
  color: var(--leaf-dark);
}

.admin-toggle.on {
  border-color: var(--leaf);
  background: var(--leaf-tint);
  color: var(--leaf-dark);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 40px;
}

.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
}

.main-actions {
  display: flex;
  gap: 10px;
}

.main-title {
  font-family: 'Source Serif 4', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
}

.crumb {
  font-family: 'Source Serif 4', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
}

.crumb-link {
  color: var(--muted);
  cursor: pointer;
}

.crumb-link:hover { color: var(--leaf-dark); }

.crumb-sep {
  font-size: 20px;
  color: var(--line-strong);
  margin: 0 8px;
}

.file-row-folder { cursor: pointer; }

.folder-chevron {
  color: var(--muted);
  cursor: default;
}

.main-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 6px;
}

.btn {
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 11px 18px;
  transition: transform 0.1s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--leaf);
  color: #FFFFFF;
}

.btn-primary:hover { background: var(--leaf-dark); }

.btn-primary:disabled {
  background: var(--panel-hi);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-ghost:hover { border-color: var(--leaf); color: var(--leaf-dark); }

.file-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.file-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--panel-hi); }

.file-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--leaf-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--leaf-dark);
}

.file-info { flex: 1; min-width: 0; }

.file-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover { border-color: var(--leaf); color: var(--leaf-dark); }

.state-block {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
}

.state-block strong {
  display: block;
  color: var(--ink);
  font-family: 'Source Serif 4', serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.state-block.err strong { color: var(--bad); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 20, 0.35);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.modal {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 24px 48px rgba(30, 43, 30, 0.16);
  transform: translateY(8px);
  transition: transform 0.15s ease;
}

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

.modal-preview {
  width: min(92vw, 880px);
  padding: 16px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-frame {
  width: 100%;
  height: min(75vh, 640px);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.modal-title {
  font-family: 'Source Serif 4', serif;
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink);
}

.modal-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}

.field input:focus {
  outline: none;
  border-color: var(--leaf);
}

.field input[type="file"] {
  padding: 9px 10px;
  font-size: 13px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.modal-actions .btn { flex: 1; }

.modal-error {
  color: var(--bad);
  font-size: 12.5px;
  margin-top: -6px;
  margin-bottom: 14px;
  min-height: 1px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--good);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13.5px;
  color: var(--ink);
  transform: translateY(12px);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 30;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.err { border-left-color: var(--bad); }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 20px 0;
  }
  .year-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 20px;
  }
  .year-item { flex-shrink: 0; }
  .sidebar-foot { padding: 16px 20px 0; }
  .main { padding: 24px 20px 32px; }
}

[tabindex]:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--leaf);
  outline-offset: 2px;
}