:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --text: #172033;
  --muted: #6f7c90;
  --line: #dbe3ee;
  --primary: #0f62fe;
  --primary-dark: #0747b6;
  --danger: #c62828;
  --danger-bg: #fff0f0;
  --shadow: 0 24px 70px rgba(33, 49, 77, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

@media (prefers-reduced-motion: no-preference) {
  :root {
    scroll-behavior: smooth;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 98, 254, 0.14), transparent 36rem),
    linear-gradient(135deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
a.ghost-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

button:focus-visible,
a.ghost-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(15, 98, 254, 0.22);
  outline-offset: 2px;
}

button[type="submit"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 98, 254, 0.24);
}

button[type="submit"]:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus {
  border-color: rgba(15, 98, 254, 0.68);
  box-shadow: 0 0 0 4px rgba(15, 98, 254, 0.1);
}

label {
  display: block;
  margin: 14px 0 7px;
  color: #344057;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 36px;
  border: 1px solid rgba(219, 227, 238, 0.78);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

@media (prefers-reduced-motion: no-preference) {
  .login-card,
  .panel,
  .content-header,
  .empty-state,
  .preview-frame {
    animation: lift-in 0.42s ease both;
  }
}

.login-card h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 8vw, 54px);
  letter-spacing: -0.06em;
}

.login-form {
  margin-top: 26px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px);
  overflow: auto;
}

.brand-block h1 {
  margin-bottom: 8px;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 35px rgba(33, 49, 77, 0.08);
}

.upload-panel,
.nav-panel {
  padding: 18px;
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button:hover {
  border-color: #aebbd0;
}

.ghost-button.disabled {
  pointer-events: none;
  color: #a4aebf;
}

.danger-button {
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid #ffd1d1;
  background: var(--danger-bg);
  color: var(--danger);
}

.logout-button {
  width: 100%;
  margin-top: auto;
}

.form-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: #167544;
}

.search-input {
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-grid label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.filter-grid select {
  margin-top: 5px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.quick-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.type-chip {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #3f4c62;
  font-size: 12px;
}

.type-chip.active {
  border-color: rgba(15, 98, 254, 0.42);
  background: rgba(15, 98, 254, 0.1);
  color: var(--primary-dark);
}

.file-tree {
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 4px;
}

.type-group,
.project-group {
  padding: 12px;
  border: 1px solid #e8eef6;
  border-radius: 16px;
  background: var(--panel-soft);
}

.type-group {
  padding: 10px;
  background: linear-gradient(180deg, #f7faff 0%, #f1f5fb 100%);
}

.type-group + .type-group {
  margin-top: 2px;
}

.project-group {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.type-summary,
.project-title {
  cursor: pointer;
  list-style: none;
}

.type-summary::-webkit-details-marker,
.project-title::-webkit-details-marker {
  display: none;
}

.type-summary {
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 900;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.count-badge {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15, 98, 254, 0.1);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.project-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
}

.month-title {
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.month-group {
  padding-left: 6px;
}

.file-button {
  width: 100%;
  margin: 4px 0;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #26344d;
  text-align: left;
}

.file-button:hover,
.file-button.active {
  border-color: #cbd9ed;
  background: #fff;
}

.file-button:hover {
  transform: translateX(2px);
}

.file-button.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

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

.file-date {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.72;
}

mark {
  border-radius: 4px;
  background: #fff0a3;
  color: inherit;
  padding: 0 2px;
}

.content-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  height: 100vh;
  padding: 22px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 35px rgba(33, 49, 77, 0.08);
}

.content-header h2 {
  max-width: min(68vw, 920px);
  margin-bottom: 0;
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: -0.03em;
}

#currentTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.empty-state,
.preview-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  place-content: center;
  padding: 28px;
  text-align: center;
}

.preview-frame {
  overflow: hidden;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .file-tree {
    max-height: 340px;
  }

  .content-shell {
    height: 72vh;
    padding-top: 0;
  }

  .content-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
