:root {
  --bg: #f5f7fb;
  --bg-elevated: rgba(255, 255, 255, 0.82);
  --panel: rgba(255, 255, 255, 0.9);
  --border: rgba(21, 36, 66, 0.1);
  --text: #10213b;
  --muted: #64748b;
  --brand: #1e5fa8;
  --brand-strong: #113f7d;
  --brand-soft: #e8f1fb;
  --green: #0f7a5d;
  --green-soft: #e5f7f0;
  --amber: #b86a08;
  --amber-soft: #fff3db;
  --rose: #b04456;
  --rose-soft: #fdecef;
  --shadow: 0 28px 60px rgba(18, 31, 56, 0.12);
  --shadow-soft: 0 14px 30px rgba(18, 31, 56, 0.08);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(30, 95, 168, 0.12), transparent 26%),
    radial-gradient(circle at top right, rgba(15, 122, 93, 0.12), transparent 22%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.bg-orb {
  position: fixed;
  inset: auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.45;
}

.orb-a {
  top: -120px;
  right: -140px;
  background: rgba(30, 95, 168, 0.25);
}

.orb-b {
  bottom: -120px;
  left: -150px;
  background: rgba(15, 122, 93, 0.22);
}

.shell {
  position: relative;
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px;
}

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

.eyebrow, .panel-kicker {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.hero h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 840px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.hero-actions,
.head-actions,
.upload-actions,
.dialog-actions,
.pill-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.dashboard {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.sidebar,
.workspace,
.inspector {
  min-height: 78vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid rgba(16, 33, 59, 0.06);
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(16, 33, 59, 0.12);
  background: rgba(255, 255, 255, 0.7);
}

.subject-list,
.file-list,
.summary-list {
  padding: 14px;
  overflow: auto;
}

.subject-card {
  border: 1px solid rgba(16, 33, 59, 0.08);
  border-radius: 20px;
  padding: 14px 14px 12px;
  background: rgba(255, 255, 255, 0.72);
  margin-bottom: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.subject-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.subject-card.active {
  border-color: rgba(30, 95, 168, 0.35);
  box-shadow: 0 18px 35px rgba(30, 95, 168, 0.1);
}

.subject-main {
  display: flex;
  gap: 12px;
  align-items: start;
}

.subject-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 5px;
  flex: 0 0 auto;
}

.subject-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  width: 100%;
}

.subject-title h3 {
  margin: 0;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.subject-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-stat {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(16, 33, 59, 0.05);
  color: #304664;
}

.add-subject,
.ghost,
.primary {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.add-subject,
.ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  border: 1px solid rgba(16, 33, 59, 0.12);
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: 0 12px 24px rgba(30, 95, 168, 0.25);
}

.tiny {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
}

.ghost:hover,
.add-subject:hover,
.primary:hover {
  transform: translateY(-1px);
}

.workspace {
  overflow: hidden;
  padding-bottom: 18px;
}

.workspace-head {
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px 0;
}

.stat-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(16, 33, 59, 0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.stat-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.stat-blue { background: linear-gradient(135deg, rgba(30,95,168,0.12), rgba(255,255,255,0.86)); }
.stat-green { background: linear-gradient(135deg, rgba(15,122,93,0.12), rgba(255,255,255,0.86)); }
.stat-amber { background: linear-gradient(135deg, rgba(184,106,8,0.12), rgba(255,255,255,0.86)); }
.stat-rose { background: linear-gradient(135deg, rgba(176,68,86,0.12), rgba(255,255,255,0.86)); }

.upload-panel,
.file-section,
.summary-panel {
  margin: 18px 22px 0;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(16, 33, 59, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

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

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
}

.file-list {
  padding: 0;
}

.file-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: 18px;
  border: 1px solid rgba(16, 33, 59, 0.08);
  background: rgba(255,255,255,0.84);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.file-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.file-icon {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
}

.file-icon.pdf { background: linear-gradient(135deg, #c74f4f, #93333d); }
.file-icon.image { background: linear-gradient(135deg, #0f7a5d, #0a5d46); }
.file-icon.docx { background: linear-gradient(135deg, #1e5fa8, #113f7d); }
.file-icon.text { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.file-icon.other { background: linear-gradient(135deg, #6b7280, #374151); }

.file-main h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.status {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.completed { background: var(--green-soft); color: var(--green); }
.status.processing { background: var(--amber-soft); color: var(--amber); }
.status.failed { background: var(--rose-soft); color: var(--rose); }
.status.uploaded { background: #e7eefc; color: var(--brand); }
.status.deleted { background: #e5e7eb; color: #475569; }

.file-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
  flex-wrap: wrap;
}

.file-actions button {
  border-radius: 12px;
  padding: 8px 12px;
  border: 1px solid rgba(16, 33, 59, 0.1);
  background: white;
}

.file-actions button.danger {
  color: var(--rose);
}

.panel-inner {
  min-height: 240px;
}

.summary-list {
  padding-top: 0;
}

.summary-card {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(16, 33, 59, 0.08);
  margin-bottom: 10px;
  background: white;
}

.summary-card h4 {
  margin: 0 0 8px;
}

.summary-card pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.75;
  color: #24344a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.inspector {
  overflow: hidden;
}

.inspector-body {
  padding: 16px 18px 22px;
  height: calc(78vh - 76px);
  overflow: auto;
}

.empty-state {
  padding: 24px 10px;
  text-align: center;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.viewer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.viewer-panel {
  border: 1px solid rgba(16, 33, 59, 0.08);
  border-radius: 20px;
  background: rgba(255,255,255,0.8);
  overflow: hidden;
}

.viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(16, 33, 59, 0.08);
  background: rgba(244, 248, 253, 0.9);
}

.viewer-head h4 {
  margin: 0;
  font-size: 0.95rem;
}

.viewer-body {
  padding: 14px;
}

.doc-preview {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(16, 33, 59, 0.08);
  background: linear-gradient(180deg, white, rgba(247,250,255,0.9));
}

.doc-preview h4 {
  margin: 0 0 6px;
}

.doc-preview .meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
}

.doc-preview .block {
  margin-bottom: 16px;
}

.doc-preview .block h5 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.doc-preview ul {
  margin: 0;
  padding-left: 18px;
  color: #24344a;
  line-height: 1.7;
}

.markdown {
  white-space: pre-wrap;
  line-height: 1.8;
  color: #24344a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.dialog {
  border: 0;
  padding: 0;
  border-radius: 24px;
  box-shadow: var(--shadow);
  width: min(560px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-card {
  padding: 18px;
  background: white;
  display: grid;
  gap: 12px;
}

.dialog-card label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
}

.dialog-card input,
.dialog-card textarea {
  border: 1px solid rgba(16, 33, 59, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fafcff;
  color: var(--text);
}

.dialog-card textarea {
  resize: vertical;
}

.loading {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
}

@media (max-width: 1320px) {
  .dashboard {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .hero,
  .upload-panel,
  .section-head,
  .upload-actions,
  .hero-actions,
  .head-actions {
    flex-direction: column;
    align-items: start;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .viewer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .file-card {
    grid-template-columns: 1fr;
  }

  .file-actions {
    justify-content: start;
  }
}
