:root {
  --bg: #efe6d3;
  --surface: #fffdf8;
  --ink: #24211c;
  --muted: #726b5c;
  --line: #dccdac;
  --line-soft: #e5d9bc;
  --accent: #8a6d3b;
  --accent-soft: #ecdfc0;
  --good: #4c7a52;
  --bad: #a34c3f;
  --radius: 3px;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --masthead-bg: #1b1712;
  --masthead-ink: #f4ecdd;
  --masthead-muted: #b3a688;
  --masthead-accent: #dcb75f;
  --masthead-line: #33291c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Masthead ---------- */

.masthead {
  background: var(--masthead-bg);
  border-bottom: 1px solid var(--masthead-line);
  flex: none;
}

/* On the home view (no tab open) the masthead grows to fill the page and
   centers the name + shortcuts panel vertically in the space below the
   social icons, instead of everything sitting pinned to the top. */
body.home {
  background: var(--masthead-bg);
}
body.home .masthead {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  border-bottom: none;
}
body.home .social-row { flex: none; }
body.home .masthead-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

main { flex: 1 0 auto; }

.social-row {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding: 18px 32px 0;
}

.social-row a {
  color: var(--masthead-muted);
  display: flex;
  transition: color 0.15s ease;
}
.social-row a:hover { color: var(--masthead-accent); }
.social-row svg { width: 26px; height: 26px; }

.masthead-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px;
  text-align: center;
}

.identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.avatar {
  width: 72px;
  height: 72px;
  flex: none;
  border-radius: 50%;
  background: var(--masthead-line);
  color: var(--masthead-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.masthead h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 46px;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--masthead-ink);
  cursor: pointer;
}
.masthead h1:hover { color: var(--masthead-accent); }

.interest-panel {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  max-width: 800px;
  margin: 44px auto 0;
}
.interest-panel[hidden] { display: none; }

.interest-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 140px;
  padding: 26px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  color: var(--ink);
  cursor: grab;
  font-family: inherit;
  font-size: 14.5px;
  touch-action: none;
  transition: box-shadow 0.12s ease;
}
.interest-tile:hover { box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24); }
.interest-tile svg { width: 30px; height: 30px; color: var(--accent); }
.interest-tile.disabled { color: var(--muted); opacity: 0.55; }
.interest-tile.disabled svg { color: var(--muted); }
.interest-tile.dragging {
  cursor: grabbing;
  z-index: 20;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  transition: none;
}

/* ---------- Layout ---------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.panel { display: none; }
.panel.active { display: block; animation: fade 0.2s ease; }

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

.panel-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 24px;
  margin: 0 0 4px;
}

.hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 16px;
}

.fetch-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  font-style: italic;
}

.subsection {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.subsection-head h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  margin: 0 0 4px;
}

/* ---------- Buttons & forms ---------- */

.btn {
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:hover { opacity: 0.82; }

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.inline-form input,
.inline-form select {
  flex: 1 1 150px;
  min-width: 120px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
}

.inline-form input:focus,
.inline-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.inline-form .btn { flex: 0 0 auto; }

/* ---------- Tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--line-soft);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table [contenteditable="true"] {
  outline: none;
  min-width: 40px;
  min-height: 18px;
}
.data-table [contenteditable="true"]:focus {
  background: var(--accent-soft);
  border-radius: 2px;
}

.data-table input[type="date"],
.data-table select {
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
  padding: 4px;
  border-radius: 2px;
}
.data-table input[type="date"]:focus,
.data-table select:focus {
  outline: none;
  border-color: var(--line);
  background: var(--accent-soft);
}

.row-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
}
.row-delete:hover { color: var(--bad); }

.empty-note {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
}
.empty-note.show { display: block; }
.data-table.has-rows { }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot.status-muted { background: #b9ac91; }
.status-dot.status-good { background: var(--good); }
.status-dot.status-accent { background: var(--accent); }
.status-dot.status-bad { background: var(--bad); }

.data-table.compact th,
.data-table.compact td {
  padding: 6px 10px;
  font-size: 12.5px;
}
.data-table.compact select,
.data-table.compact input[type="date"] {
  font-size: 12.5px;
  padding: 2px;
}

.row-num {
  color: var(--muted);
  width: 1%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Programs ---------- */

.program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 16px;
}

.program-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
}

.program-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.program-link {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.program-link:hover { color: var(--accent); text-decoration: underline; }

.program-deadline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}
.program-window-text {
  font-size: 15px;
  color: var(--muted);
}
.contact-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
}
.contact-row:last-child { border-bottom: none; }

.contact-role {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  min-width: 110px;
}

.contact-name {
  flex: 0 1 auto;
  font-weight: 500;
}

.contact-email {
  flex: 1 1 220px;
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
  white-space: normal;
}
.contact-email:hover { text-decoration: underline; }

.program-notes {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
  min-height: 18px;
  margin: 0 0 12px;
}
.program-notes:empty::before {
  content: attr(data-placeholder);
  opacity: 0.6;
}

/* ---------- Stat row ---------- */

.stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-box {
  flex: 1 1 140px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-box .num {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
}

.stat-box .label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Theme grid (markets + watchlist, categorized) ---------- */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 8px;
}

.theme-square {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  cursor: grab;
  touch-action: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.theme-square.dragging {
  cursor: grabbing;
  position: relative;
  z-index: 20;
  border-color: var(--accent);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.theme-square h4 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.tsr {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  font-size: 15px;
}

.tsr-ticker {
  font-weight: 600;
  flex: 0 0 auto;
  min-width: 58px;
}

.tsr-name {
  flex: 1 1 auto;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tsr-price {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.tsr-change {
  flex: 0 0 auto;
  font-size: 13px;
  min-width: 62px;
  text-align: right;
}
.tsr-change.up { color: var(--good); }
.tsr-change.down { color: var(--bad); }
.tsr-change.flat { color: var(--muted); }

.tsr-link {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.tsr-notes {
  margin: -2px 0 8px;
  padding-left: 2px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--muted);
}

/* ---------- Economic indicator cards ---------- */

.econ-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.econ-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.econ-card h4 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 16px;
}

.econ-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.econ-field label {
  font-size: 12.5px;
  color: var(--muted);
  flex: 1;
}

.econ-field input {
  width: 130px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
  text-align: right;
}

.econ-sub {
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  margin: -4px 0 8px;
}

.table-scroll {
  overflow-x: auto;
}

.econ-card .source-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
}
.econ-card .source-link:hover { text-decoration: underline; }

/* ---------- Biotech ---------- */

.source-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.source-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.source-btn:hover { border-color: var(--accent); color: var(--accent); }
.source-btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.news-feed {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

.news-feed > p.hint {
  grid-column: 1 / -1;
  margin: 0 0 4px;
}

.news-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  cursor: grab;
  touch-action: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.news-item.dragging {
  cursor: grabbing;
  position: relative;
  z-index: 20;
  border-color: var(--accent);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.news-item .src {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.news-item h4 {
  margin: 6px 0 6px;
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
}
.news-item h4 a { color: var(--ink); text-decoration: none; }
.news-item h4 a:hover { text-decoration: underline; }

.news-item p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}

.news-item .date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  display: block;
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.note-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13.5px;
}

.note-list .note-meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex: none;
}

@media (max-width: 640px) {
  .masthead h1 { font-size: 30px; }
  .avatar { width: 52px; height: 52px; font-size: 20px; }
  main { padding: 24px 16px 60px; }
}
