/* ==========================================================================
   ACADEMIC LIBRARY HUB — ZEN MINIMALIST ARCHITECTURE
   Notion / Linear Clean Discipline — Zero Visual Noise
   ========================================================================== */

:root, [data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-subtle: #f4f4f5;
  --surface-hover: #f0f0f2;
  --border: #e4e4e7;
  --border-hover: #a1a1aa;
  --ink: #18181b;
  --ink-secondary: #52525b;
  --ink-muted: #71717a;
  --ink-inverse: #ffffff;
  --accent: #18181b;
  --tag-bg: #f4f4f5;
  --tag-ink: #3f3f46;
  --header-bg: rgba(250, 250, 250, 0.85);
  --success: #16a34a;
}

:root[data-theme="dark"], html[data-theme="dark"], body[data-theme="dark"], [data-theme="dark"] {
  --bg: #090a0c;
  --surface: #111317;
  --surface-subtle: #181a20;
  --surface-hover: #1f222a;
  --border: #1f222a;
  --border-hover: #3f4452;
  --ink: #f4f4f6;
  --ink-secondary: #9ea2b0;
  --ink-muted: #656976;
  --ink-inverse: #090a0c;
  --accent: #f4f4f6;
  --tag-bg: #181a20;
  --tag-ink: #a1a4b2;
  --header-bg: rgba(9, 10, 12, 0.85);
  --success: #22c55e;
}

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

html, body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 120ms ease, color 120ms ease;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  letter-spacing: -0.02em;
}

a { color: inherit; text-decoration: none; }
button, input { font-family: inherit; font-size: inherit; border: none; outline: none; background: transparent; }

/* Layout & Header */
.app-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.brand-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  background-color: var(--tag-bg);
  color: var(--tag-ink);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 120ms ease;
}

.theme-toggle-btn:hover { background-color: var(--surface-hover); color: var(--ink); border-color: var(--border-hover); }

[data-theme="dark"] .theme-icon-light { display: inline-block; }
[data-theme="dark"] .theme-icon-dark { display: none; }
:root:not([data-theme="dark"]) .theme-icon-light { display: none; }
:root:not([data-theme="dark"]) .theme-icon-dark { display: inline-block; }

/* Main Container */
.main-content {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* Page Intro Header */
.page-intro {
  margin-bottom: 28px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--ink-secondary);
}

/* Minimal Search Bar */
.search-container {
  position: relative;
  margin-bottom: 24px;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 120ms ease;
}

.search-input:focus { border-color: var(--border-hover); }
.search-icon-svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }
.search-clear-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); cursor: pointer; display: flex; }

/* Zen Subject List (Clean Rows) */
.subject-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--surface);
  overflow: hidden;
}

.subject-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 120ms ease;
  gap: 16px;
}

.subject-row:last-child { border-bottom: none; }
.subject-row:hover { background-color: var(--surface-hover); }

.subject-main-info {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.subject-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.subject-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-meta-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.subject-pill {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  background-color: var(--tag-bg);
  color: var(--tag-ink);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.chevron-icon { color: var(--ink-muted); display: flex; }

/* Detail Page */
.detail-top-nav {
  margin-bottom: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  transition: color 120ms ease;
}

.back-link:hover { color: var(--ink); }

.subject-header-area {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-subject-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.detail-subject-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

/* Minimal Tab Bar */
.detail-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.detail-tab-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 120ms ease;
}

.detail-tab-btn:hover { color: var(--ink); }
.detail-tab-btn.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.tab-badge { font-family: 'JetBrains Mono', monospace; font-size: 11px; margin-left: 4px; color: var(--ink-muted); }

.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

/* Minimal File List (Finder / Notion Style) */
.file-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  overflow: hidden;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.file-row:last-child { border-bottom: none; }

.file-info-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-format-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  background-color: var(--tag-bg);
  border: 1px solid var(--border);
  color: var(--tag-ink);
}

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

.file-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.file-size-text {
  font-size: 12px;
  color: var(--ink-muted);
}

.file-view-btn {
  padding: 4px 10px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.file-view-btn:hover { background-color: var(--ink); color: var(--ink-inverse); border-color: var(--ink); }

/* Minimal Syllabus Checklist */
.syllabus-clean-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.syllabus-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 120ms ease;
}

.syllabus-row.is-done { opacity: 0.6; }
.syllabus-row.is-done .syllabus-row-title { text-decoration: line-through; }

.clean-checkbox {
  margin-top: 3px;
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
}

.syllabus-row-body { flex: 1; min-width: 0; }
.syllabus-row-week { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-muted); font-weight: 600; }
.syllabus-row-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.syllabus-row-desc { font-size: 12px; color: var(--ink-secondary); line-height: 1.5; }

/* Notes / Markdown */
.clean-notes-box {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  line-height: 1.7;
  font-size: 14px;
}

.clean-notes-box h3 { font-size: 16px; margin: 18px 0 8px; color: var(--ink); }
.clean-notes-box h3:first-child { margin-top: 0; }
.clean-notes-box ul { padding-left: 20px; margin-bottom: 14px; color: var(--ink-secondary); }
.clean-notes-box code { font-family: 'JetBrains Mono', monospace; font-size: 0.85em; background-color: var(--surface-subtle); border: 1px solid var(--border); padding: 2px 5px; border-radius: 4px; color: var(--ink); }
.clean-notes-box pre { background-color: var(--surface-subtle); color: var(--ink); padding: 14px; border-radius: 6px; border: 1px solid var(--border); overflow-x: auto; margin-bottom: 14px; }
.clean-notes-box pre code { border: none; padding: 0; }

/* Links List */
.clean-links-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clean-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 120ms ease;
}

.clean-link-item:hover { border-color: var(--border-hover); background-color: var(--surface-hover); }
.clean-link-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.clean-link-desc { font-size: 12px; color: var(--ink-muted); }

/* Document Preview Modal */
.preview-modal-backdrop { position: fixed; inset: 0; z-index: 100; background-color: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 14px; opacity: 0; pointer-events: none; transition: opacity 120ms ease; }
.preview-modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.preview-modal-container { width: 100%; max-width: 1000px; height: 90vh; background-color: var(--surface); border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.preview-modal-header { padding: 10px 16px; background-color: var(--surface-subtle); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.preview-modal-title { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-close-btn { width: 26px; height: 26px; border-radius: 4px; border: 1px solid var(--border); background-color: var(--surface); color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.modal-close-btn:hover { background-color: var(--surface-hover); }

.preview-modal-body { flex: 1; background-color: #090a0c; }
.preview-modal-iframe { width: 100%; height: 100%; border: none; }
.preview-fallback-box { padding: 48px 24px; text-align: center; color: var(--ink); max-width: 440px; margin: 0 auto; }

/* Site Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: auto; padding: 20px; font-size: 12px; color: var(--ink-muted); text-align: center; }

/* Responsive */
@media (max-width: 640px) {
  .subject-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .subject-meta-side { width: 100%; justify-content: space-between; }
  .file-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .file-actions-right { width: 100%; justify-content: space-between; }
}
