@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Mono:wght@300;400;500&family=Syne:wght@400;500;700;800&display=swap');

:root {
  --bg: #F5EDD8;
  --surface: #FFFFFF;
  --border: #DDD5C0;
  --accent: #8C1515;
  --accent-dim: #B03030;
  --text: #2E2D29;
  --text-muted: #6B5E5E;
  --text-dim: #A09080;
  --tag-bg: #F2EDE3;
  --tag-border: #D2C295;
  --danger: #c0392b;
  --info: #175E54;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── NAV ── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245,237,216,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 2rem; height: 56px; gap: 2rem;
}
.nav-logo {
  font-family: 'Syne', sans-serif;
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.nav-logo-text {
  display: flex; flex-direction: column; line-height: 1.15;
  font-weight: 700; font-size: 12px; letter-spacing: 0;
  color: var(--accent);
}
.nav-logo-sub {
  font-weight: 400; font-size: 9px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
}
.nav-mushroom { flex-shrink: 0; }
.nav-links { display: flex; gap: 0; margin-left: auto; }
.nav-links a {
  color: var(--text-muted); text-decoration: none;
  padding: 0 1rem; height: 56px; display: flex;
  align-items: center; font-size: 12px; letter-spacing: 0.05em;
  text-transform: uppercase; transition: color 0.15s;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-btn {
  background: var(--accent); color: #ffffff;
  border: none; padding: 7px 16px; border-radius: 4px;
  font-family: 'DM Mono', monospace; font-size: 12px;
  font-weight: 500; cursor: pointer; letter-spacing: 0.03em;
  text-transform: uppercase; margin-left: 1rem;
  text-decoration: none; display: inline-flex; align-items: center;
}

/* ── MESSAGES ── */
.messages { max-width: 1100px; margin: 1rem auto; padding: 0 2rem; }
.message {
  padding: 10px 16px; border-radius: 4px; margin-bottom: 8px;
  font-size: 12px; border: 1px solid;
}
.message.success { background: rgba(192,57,43,0.08); border-color: rgba(192,57,43,0.3); color: var(--accent-dim); }
.message.error { background: rgba(240,122,48,0.08); border-color: rgba(240,122,48,0.3); color: var(--danger); }

/* ── HERO ── */
.hero {
  padding: 80px 2rem 60px;
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4rem;
  align-items: center;
}
.hero-label {
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent-dim); margin-bottom: 1rem;
}
.hero h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.1; color: var(--text);
  margin-bottom: 1.5rem;
}
.hero h1 em { color: var(--accent); font-style: italic; }
.hero p { color: var(--text-muted); font-size: 14px; line-height: 1.8; margin-bottom: 2rem; }
.hero-stats { display: flex; gap: 2rem; }
.stat { border-left: 2px solid var(--border); padding-left: 1rem; }
.stat-n {
  font-family: 'Syne', sans-serif; font-weight: 700;
  font-size: 28px; color: var(--accent); line-height: 1;
}
.stat-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }

.hero-search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 2rem;
}
.search-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 1rem; }
.search-input-wrap { display: flex; gap: 8px; margin-bottom: 1rem; }
.search-input {
  flex: 1; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 10px 14px; color: var(--text);
  font-family: 'DM Mono', monospace; font-size: 13px; outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }
.btn-accent {
  background: var(--accent); color: #ffffff;
  border: none; padding: 10px 20px; border-radius: 4px;
  font-family: 'DM Mono', monospace; font-size: 12px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn-outline {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); padding: 8px 16px;
  border-radius: 4px; font-family: 'DM Mono', monospace;
  font-size: 12px; cursor: pointer;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--tag-bg); border: 1px solid var(--tag-border);
  border-radius: 3px; padding: 4px 10px; font-size: 11px;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
  text-transform: uppercase; letter-spacing: 0.05em;
  text-decoration: none; display: inline-block;
}
.chip:hover, .chip.active { border-color: var(--accent); color: var(--accent); background: rgba(192,57,43,0.06); }

/* ── DATASET LIST ── */
.section { max-width: 1100px; margin: 0 auto; padding: 0 2rem 4rem; }
.section-header {
  display: flex; align-items: baseline; gap: 1rem;
  border-bottom: 1px solid var(--border); padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}
.section-title {
  font-family: 'Syne', sans-serif; font-weight: 700;
  font-size: 16px; letter-spacing: -0.3px;
}
.section-count { color: var(--text-muted); font-size: 12px; }
.sort-controls { margin-left: auto; display: flex; gap: 8px; }
.sort-controls .btn-outline.active { border-color: var(--accent); color: var(--accent); }

/* ── Advanced Filters ── */
.adv-filters { margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.adv-filters-toggle {
  list-style: none; cursor: pointer;
  padding: 8px 12px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.adv-filters-toggle::-webkit-details-marker { display: none; }
.adv-filters[open] .adv-filters-toggle { border-bottom: 1px solid var(--border); color: var(--accent); }
.adv-active-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }
.adv-filters-grid { padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.adv-filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.adv-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }
.adv-select {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 8px; font-family: 'DM Mono', monospace; font-size: 12px;
  color: var(--text); cursor: pointer; height: 30px; box-sizing: border-box;
}
.adv-select:focus { outline: none; border-color: var(--accent); }
select.adv-select { appearance: none; -webkit-appearance: none; }

.dataset-grid { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.dataset-row {
  background: var(--surface); padding: 1.25rem 1.5rem;
  display: grid; grid-template-columns: 1fr auto;
  gap: 1rem; align-items: start;
  transition: background 0.1s; text-decoration: none;
}
.dataset-row:hover { background: #F2EDE3; }
.ds-name {
  font-family: 'Syne', sans-serif; font-weight: 600;
  font-size: 14px; color: var(--text); margin-bottom: 4px;
}
.dataset-row:hover .ds-name { color: var(--accent); }
.ds-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.ds-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  background: var(--tag-bg); border: 1px solid var(--tag-border);
  border-radius: 3px; padding: 2px 8px; font-size: 10px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.tag.green { border-color: rgba(192,57,43,0.3); color: var(--accent-dim); background: rgba(192,57,43,0.04); }
.tag.blue { border-color: rgba(224,144,96,0.3); color: var(--info); background: rgba(224,144,96,0.04); }
.ds-right { text-align: right; }
.ds-size { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ds-date { font-size: 11px; color: var(--text-dim); }
.nb-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(192,57,43,0.08); border: 1px solid rgba(192,57,43,0.2);
  border-radius: 3px; padding: 2px 8px; font-size: 10px;
  color: var(--accent-dim); margin-top: 0;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px;
}
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }

/* ── DETAIL PAGE ── */
.detail-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 2.5rem 2rem 0;
}
.detail-inner { max-width: 1100px; margin: 0 auto; }
.breadcrumb { font-size: 11px; color: var(--text-muted); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 6px; }
.detail-title {
  font-family: 'Instrument Serif', serif;
  font-size: 36px; line-height: 1.2; margin-bottom: 0.75rem;
}
.detail-byline { color: var(--text-muted); font-size: 12px; margin-bottom: 1.5rem; }
.detail-tabs { display: flex; gap: 0; margin-top: 1rem; }
.dtab {
  padding: 12px 20px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.15s;
}
.dtab:hover { color: var(--text); }
.dtab.active { color: var(--accent); border-bottom-color: var(--accent); }

.detail-body { max-width: 1100px; margin: 0 auto; padding: 2rem; display: grid; grid-template-columns: 1fr 280px; gap: 2rem; }

.info-block { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1.25rem; margin-bottom: 1rem; }
.info-block-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 1rem; }
.info-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--text-muted); }
.info-val { color: var(--text); text-align: right; }

.dl-btn {
  width: 100%; background: var(--accent); color: #ffffff;
  border: none; padding: 12px; border-radius: 4px;
  font-family: 'DM Mono', monospace; font-size: 13px;
  font-weight: 500; cursor: pointer; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.open-btn {
  width: 100%; background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); padding: 10px;
  border-radius: 4px; font-family: 'DM Mono', monospace;
  font-size: 12px; cursor: pointer; margin-bottom: 6px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.open-btn:hover { border-color: var(--text-muted); color: var(--text); }

/* ── FILE LIST ── */
.file-list { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.file-row {
  background: var(--surface); padding: 0.75rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  font-size: 12px;
}
.file-row:hover { background: #F2EDE3; }
.file-name { color: var(--text); flex: 1; }
.file-size { color: var(--text-muted); }
.file-dl { color: var(--accent-dim); text-decoration: none; font-size: 11px; }
.file-dl:hover { color: var(--accent); }

/* ── NOTEBOOK VIEWER ── */
.nb-viewer { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 1rem; }
.nb-toolbar {
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.nb-title { font-size: 12px; color: var(--text-muted); }
.nb-badge-sm {
  background: rgba(192,57,43,0.1); border: 1px solid rgba(192,57,43,0.25);
  border-radius: 3px; padding: 2px 8px; font-size: 10px; color: var(--accent-dim);
}

/* ── UPLOAD ── */
.upload-wrap { max-width: 680px; margin: 3rem auto; padding: 0 2rem; }
.upload-title { font-family: 'Instrument Serif', serif; font-size: 32px; margin-bottom: 0.5rem; }
.upload-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 2rem; }
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1.5rem; margin-bottom: 1rem; }
.form-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 1.25rem; }
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 10px 14px; color: var(--text);
  font-family: 'DM Mono', monospace; font-size: 13px; outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { appearance: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dropzone {
  border: 2px dashed var(--border); border-radius: 6px;
  padding: 2.5rem; text-align: center; cursor: pointer;
  transition: all 0.2s; position: relative;
}
.dropzone:hover { border-color: var(--accent); background: rgba(192,57,43,0.03); }
.dropzone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dz-icon { font-size: 28px; margin-bottom: 0.75rem; }
.dz-text { color: var(--text-muted); font-size: 13px; margin-bottom: 0.5rem; }
.dz-hint { color: var(--text-dim); font-size: 11px; }
.submit-bar { display: flex; gap: 1rem; justify-content: flex-end; padding-top: 1rem; }
.form-errors { color: var(--danger); font-size: 11px; margin-top: 4px; }

/* ── AUTH ── */
.auth-wrap { max-width: 400px; margin: 5rem auto; padding: 0 2rem; }
.auth-logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 22px; color: var(--accent); margin-bottom: 2rem; }
.auth-title { font-family: 'Instrument Serif', serif; font-size: 28px; margin-bottom: 0.5rem; }
.auth-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 2rem; }
.auth-box { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2rem; }
.auth-divider { text-align: center; color: var(--text-dim); font-size: 11px; margin: 1.25rem 0; position: relative; }
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 40%;
  height: 1px; background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }
.auth-footer { color: var(--text-muted); font-size: 12px; text-align: center; margin-top: 1.5rem; }
.auth-footer a { color: var(--accent-dim); }

/* misc */
.accent { color: var(--accent); }
.muted { color: var(--text-muted); }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.pill { display: inline-block; background: rgba(192,57,43,0.1); color: var(--accent); border-radius: 20px; padding: 2px 10px; font-size: 11px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  /* Nav */
  nav { padding: 0 1rem; gap: 1rem; }
  .nav-links { display: none; }
  .nav-btn { padding: 6px 12px; font-size: 11px; margin-left: auto; }

  /* Hero */
  .hero { grid-template-columns: 1fr; gap: 1.5rem; padding: 32px 1rem 24px; }
  .hero h1 { font-size: clamp(26px, 7vw, 40px); margin-bottom: 1rem; }
  .hero p { font-size: 13px; margin-bottom: 1.5rem; }
  .hero-stats { gap: 1.25rem; }

  /* Sections & cards */
  .section { padding: 0 1rem 2rem; }
  .messages { padding: 0 1rem; }
  .dataset-row { padding: 1rem; gap: .5rem; }
  .ds-right { text-align: left; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

  /* Detail header */
  .detail-header { padding: 1.25rem 1rem 0; }
  .detail-inner { padding: 0; }
  .detail-title { font-size: clamp(20px, 6vw, 30px); margin-bottom: .5rem; }
  .detail-byline { font-size: 11px; }
  .detail-tabs { overflow-x: auto; white-space: nowrap; padding-bottom: 2px; }
  .dtab { padding: 10px 14px; font-size: 11px; }
  .detail-body { padding: 1rem; gap: 1rem; }

  /* Grids */
  .detail-body { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }

  /* Sample toolbar */
  .sample-toolbar { gap: 8px; }
  .sample-col-input { width: 130px; }

  /* Upload / forms */
  .upload-wrap { padding: 0 1rem; margin: 1.5rem auto; }

  /* Expanded view: shrink photo to fit phone */
  .sample-table.expanded-view .sample-photo-td img { max-width: 120px !important; max-height: 160px !important; width: auto !important; height: auto !important; }
  .sample-table.expanded-view tbody tr { gap: 12px; padding: 14px 0; }
  .sample-table.expanded-view, .sample-table.expanded-view tbody { max-width: 100%; }
}

/* ── SAMPLE TABLE ── */
.sample-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 1rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.sample-col-input {
  font-family: 'DM Mono', monospace; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 10px; color: var(--text);
  width: 180px;
}
.sample-col-input:focus { outline: none; border-color: var(--accent); }
.sample-table-wrap { overflow-x: auto; padding: 0 2vw; }
.sample-table {
  border-collapse: collapse;
  font-size: clamp(9px, 1.1vw, 12px);
  width: auto;
  margin: 0 auto;
}
.detail-body.samples-active { grid-template-columns: 1fr; max-width: 100%; padding: 2rem 0; }
.detail-body.samples-active .detail-sidebar { display: none; }
.sample-table th {
  text-align: left; padding: clamp(4px, 0.55vw, 7px) clamp(5px, 0.9vw, 12px);
  background: var(--tag-bg); border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-weight: 500; white-space: nowrap;
}
.sample-table td {
  padding: clamp(4px, 0.55vw, 7px) clamp(5px, 0.9vw, 12px);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted); vertical-align: middle; white-space: nowrap;
}
.sample-table tbody tr:hover { background: var(--tag-bg); }
.sample-id-cell { color: var(--text); font-weight: 500; }
.col-del-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 14px; padding: 0 4px;
  line-height: 1;
}
.col-del-btn:hover { color: var(--danger); }

/* ── NOTEBOOK CODE BLOCK ── */
.nb-code {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  white-space: pre;
  border-radius: 0 0 6px 6px;
  margin: 0;
}
