/* craig.trading. Layout is mobile first: phone below 640px, tablet 640–1023px, desktop from 1024px. */

:root {
  color-scheme: dark;
  --ground: #09090b;
  --surface: #18181b;
  --surface-raised: #27272a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --border-badge: #52525b;
  --text: #fafafa;
  --text-soft: #d4d4d8;
  --muted: #a1a1aa;
  --dim: #80808a;
  --market: #60a5fa;
  --market-soft: rgba(96, 165, 250, 0.15);
  --market-strong: rgba(96, 165, 250, 0.35);
  /* Ticker colors, named in config/watchlist.json (WATCHLIST_COLORS in src/validate.js). */
  --ticker-green: #34d399;
  --ticker-amber: #f59e0b;
  --ticker-violet: #a78bfa;
  --ticker-rose: #fb7185;
  --ticker-cyan: #22d3ee;
  --ticker-lime: #a3e635;
  --ticker-orange: #fb923c;
  --ticker-pink: #f472b6;
  --high: #fde68a;
  --open: #4ade80;
  --focus: #93c5fd;
  --link-hover: #93c5fd;
  --danger-text: #fca5a5;
  --danger-border-strong: #f87171;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--link-hover); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Login: market clock ---------- */

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 32px 56px;
}

.login-brand {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.login-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 40px;
  max-width: 640px;
}

.clock {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clock p { margin: 0; }

.clock-date {
  font-size: 18px;
  color: var(--muted);
}

.clock-time {
  font-size: 64px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.clock-suffix {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.market {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.market-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.market-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.market-dot.filled { background: var(--open); }
.market-dot.hollow { border: 2px solid var(--muted); }

.market-sub {
  font-size: 16px;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}

.login-row {
  display: flex;
  gap: 8px;
}

.login-row input,
.login-row button {
  height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.login-row input {
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
}

.login-row input::placeholder { color: var(--muted); }
.login-row input[aria-invalid="true"] { border-color: var(--danger-border-strong); }

.login-row button {
  flex: none;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  background: var(--surface-raised);
  color: var(--text);
}

.login-row button:hover { background: var(--border-strong); }
.login-row button:disabled { color: var(--muted); cursor: not-allowed; }

.login-error {
  margin: 0;
  font-size: 14px;
  color: var(--danger-text);
}

@media (max-width: 1023px) {
  .login-shell { padding: 28px 32px; }
}

@media (max-width: 639px) {
  .login-shell { padding: 24px 20px 32px; }
  .login-main { justify-content: flex-end; gap: 36px; max-width: none; }
  .clock { gap: 10px; }
  .clock-date { font-size: 16px; }
  .clock-time { font-size: 56px; }
  .clock-suffix { font-size: 24px; }
  .market-line { font-size: 16px; }
  .market-sub { font-size: 15px; }
  .login-form { max-width: none; }
  .login-row input, .login-row button { height: 52px; }
}

/* ---------- Calendar: header ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 4px 16px;
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 17px; }

.header-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.header-meta .tz-long { display: none; }

.signout {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.signout:hover { background: var(--surface); }

/* ---------- Calendar: page layout ---------- */

.page {
  display: flex;
  flex-direction: column;
}

.sidebar { display: none; }

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'switch filters'
    'chips chips'
    'picker picker'
    'title title';
  align-items: center;
  gap: 8px;
  padding: 12px 16px 8px;
}

.view-switch { grid-area: switch; }
.filters-button { grid-area: filters; }
.chips-phone { grid-area: chips; }
.chips-tablet { grid-area: chips; }
.month-picker { grid-area: picker; }

.title {
  grid-area: title;
  margin: 0;
  font-size: 20px;
}

/* The phone layout has no visible heading; the view switch and month picker carry it. */
@media (max-width: 639.98px) {
  .title {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* View switch: a segmented control on phone and tablet, two buttons on desktop. */
.view-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  background: var(--surface);
  border-radius: 8px;
}

.view-switch button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.view-switch button[aria-pressed='true'] {
  background: var(--border-strong);
  color: var(--text);
  font-weight: 600;
}

.filters-button {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

/* Month picker */
.month-picker {
  display: grid;
  grid-template-columns: repeat(var(--months, 4), minmax(0, 1fr));
  gap: 6px;
}

.month-picker button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

/* Seven months share the phone's width, so the grid sizes each button. */
@media (max-width: 639.98px) {
  .month-picker button { padding: 0; }
}

.month-picker button[aria-pressed='true'] {
  border-color: var(--text);
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 600;
}

/* Chips */
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  white-space: nowrap;
}

.chip[aria-pressed='true'] {
  border-color: var(--text);
  background: var(--surface-raised);
  color: var(--text);
}

/* Market and ticker chips are on/off toggles: on is filled and outlined in its color, off is a hollow dot. */
.chip-market,
.chip-ticker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
}

.chip-market { --tick: var(--market); }

.chip-market .dot,
.chip-ticker .dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--tick);
}

.chip.chip-market[aria-pressed='true'],
.chip.chip-ticker[aria-pressed='true'] {
  border-color: var(--tick);
  background: var(--surface-raised);
  color: var(--text);
}

.chip-market[aria-pressed='true'] .dot,
.chip-ticker[aria-pressed='true'] .dot { background: var(--tick); }

.chips-phone {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 4px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips-phone::-webkit-scrollbar { display: none; }

.chips-tablet { display: none; }

/* ---------- Main area ---------- */

.main {
  padding: 4px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.status-message {
  margin: 0;
  color: var(--muted);
}

.unavailable {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.unavailable p { margin: 0; }

.retry {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.retry:hover { background: var(--surface-raised); }

/* Agenda */
.agenda {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.month-heading {
  margin: 4px 0 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

.day-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-heading {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* Event rows. Phone shows dot + two lines; tablet and desktop use the four-column grid. */
.event-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
}

.event .when,
.event .importance { display: none; }

.event .estimated { display: none; }

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--market);
}

.dot.watch { border-radius: 1px; background: var(--tick); }

.event-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.event-title { overflow-wrap: anywhere; }
.event.high .event-title { font-weight: 600; }
.ticker { font-weight: 700; }

.event-meta,
.event-note {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.high-text { color: var(--high); font-weight: 600; }

.event-note a {
  color: var(--text-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline-block;
  line-height: 24px;
  /* A 44px tap target that takes no extra room in the row. */
  padding: 10px 8px;
  margin: -10px -8px;
}

.event-note a:hover { color: var(--link-hover); }

.estimated {
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid var(--border-badge);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.closed-row {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--muted);
  list-style: none;
}

/* Month grid */
.month-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.weekday {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.weekday .long { display: none; }

.cell {
  min-width: 0;
  height: 48px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  text-align: left;
}

.cell .date { font-size: 15px; line-height: 1; }
.cell .mon-prefix { display: none; }
.cell.has-events { color: var(--text); }
.cell.has-high .date { font-weight: 700; }
.cell.past { background: transparent; border-color: var(--border); color: var(--dim); }
.cell.past.has-events { color: var(--muted); }
.cell.today .date { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.cell.closed {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--dim);
}

.cell.closed .date { text-decoration: line-through; }

.cell[aria-pressed='true'] {
  background: var(--surface-raised);
  /* The second pixel of the ring is a shadow, so selecting a day never moves or narrows its contents. */
  border-style: solid;
  border-color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
  color: var(--text);
}

.cell.outside {
  background: transparent;
  color: var(--dim);
}

.cell.outside.closed { border-color: var(--border); }

.cell .chips,
.cell .closed-label { display: none; }

.dots {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 8px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
}

.dots .dot { width: 7px; height: 7px; }

.selected-day {
  margin: 0 -16px;
  padding: 14px 16px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selected-day h2 { margin: 0; font-size: 15px; }

.selected-day .status-message { font-size: 14px; }

/* ---------- Filters sheet (phone) ---------- */

.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 85vh;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--border-strong);
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  color: var(--text);
}

.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }

.sheet-inner {
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-header h2 { margin: 0; font-size: 16px; }

.sheet-done {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

/* Filter controls, shared by the sidebar and the sheet */
.filter-section {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-section h2,
.filter-section h3 {
  margin: 0 0 6px;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--market);
}

.check .dot { width: 8px; height: 8px; }

.ticker-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* A watchlist row is an on/off switch for that ticker's events. */
.ticker-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.ticker-button:hover { background: var(--surface); }
.ticker-button[aria-pressed='false'] .swatch,
.ticker-button[aria-pressed='false'] .ticker-label { opacity: 0.5; }

.ticker-button .swatch {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 3px;
  background: var(--tick);
}

.ticker-label { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ticker-button .symbol { font-weight: 600; }
.ticker-button .state { color: var(--muted); font-size: 13px; }

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: 10px;
  background: var(--border-strong);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ground);
}

.ticker-button[aria-pressed='true'] .switch { background: var(--tick); }
.ticker-button[aria-pressed='true'] .switch::after { left: 18px; }

/* ---------- Header navigation (signed-in pages) ---------- */

/* On a phone the navigation takes its own row under the brand, as a two-part switch. */
.site-header { flex-wrap: wrap; }

.site-nav {
  order: 1;
  flex: 1 0 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin: 4px 8px 8px 0;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface);
}

.site-nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.site-nav a[aria-current='page'] { background: var(--border-strong); color: var(--text); font-weight: 600; }

/* ---------- Overview ---------- */

.header-clock { display: none; }
.header-session[data-session='pre'],
.header-session[data-session='after'] { color: var(--high); }
.header-session[data-session='open'] { color: var(--open); }

.stripe {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border);
}

.market-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.market-tabs::-webkit-scrollbar { display: none; }

.market-tabs button {
  flex: none;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.market-tabs button:hover { color: var(--text); }
.market-tabs button[aria-selected='true'] { background: var(--surface-raised); color: var(--text); }

/* The quotes widget lays its tiles out across its width, so a phone scrolls it sideways, without a scrollbar,
   like the tabs above it. */
.quotes-scroll {
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: none;
}

.quotes-scroll::-webkit-scrollbar { display: none; }

.quotes-frame { position: relative; min-width: 760px; }
.quotes { min-height: 72px; }

/* The widget's own tiles link to TradingView, so a row of buttons lies over them, one per quote in the
   widget's equal columns, and each puts its symbol on the chart. */
.quote-buttons {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--quotes, 5), minmax(0, 1fr));
}

.quote-buttons button {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.quote-buttons button:hover { background: rgba(255, 255, 255, 0.04); }
.quote-buttons button[aria-pressed='true'] { box-shadow: inset 0 -2px 0 var(--focus); }

.overview {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px 16px 32px;
}

.chart-panel {
  height: 360px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #111113;
}

.chart { height: 100%; }
.chart .tradingview-widget-container__widget { height: 100%; }

.overview-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.side-section h2 { margin: 0; font-size: 16px; }

.today-list,
.watch-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.today-list { gap: 8px; }

.today-event {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  grid-template-areas: 'dot title' '. when';
  gap: 2px 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
}

.today-event .dot { grid-area: dot; }
.today-event .today-title { grid-area: title; font-weight: 600; }
.today-event .when { grid-area: when; color: var(--muted); font-size: 13px; }

.next-events {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watch-item {
  position: relative;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 200px;
  gap: 12px;
  align-items: center;
  padding-left: 8px;
  border-bottom: 1px solid var(--surface);
}

.watch-item .swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--tick); }

.watch-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.watch-symbol { font-weight: 600; }

/* A widget's frame is drawn light by default, which puts a white backdrop behind a transparent widget on this
   dark page; asking for light inside the frame lets the page show through. */
.tradingview-widget-container iframe { color-scheme: light; }

.watch-quote { height: 72px; }

/* Lies over the whole row, quote included, and opens the ticker's page. */
.watch-row {
  position: absolute;
  inset: 0;
}

.watch-row:hover { background: rgba(255, 255, 255, 0.04); }

.watch-next {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Tablet ---------- */

@media (min-width: 640px) {
  .site-header { gap: 24px; padding: 6px 16px 6px 24px; }
  .brand { font-size: 18px; }
  .header-meta .tz-short { display: none; }
  .header-meta .tz-long { display: inline; }

  .toolbar {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      'switch picker'
      'chips chips'
      'title title';
    gap: 14px 12px;
    padding: 20px 24px 0;
  }

  .view-switch { grid-template-columns: repeat(2, 104px); }
  .month-picker { justify-self: end; }
  .title { margin-top: 4px; }
  .filters-button,
  .chips-phone { display: none; }

  .chips-tablet { display: flex; flex-wrap: wrap; gap: 8px; }

  .month-picker { display: flex; }

  .main { padding: 12px 24px 40px; gap: 24px; }

  .agenda { gap: 24px; }
  .month-heading { margin-top: 8px; padding-bottom: 8px; font-size: 18px; }
  .day-group { gap: 8px; }
  .day-heading { font-size: 14px; }
  .event-list { gap: 8px; }

  .event {
    grid-template-columns: 92px 8px minmax(0, 1fr) auto;
    gap: 14px;
    min-height: 48px;
    padding: 12px 16px;
  }

  .event .when { display: block; color: var(--muted); }
  .event .importance { display: block; font-size: 13px; color: var(--muted); }
  .event .importance.high-text { color: var(--high); font-weight: 600; }
  .event .estimated { display: inline-block; }
  .event .event-meta { display: none; }

  .closed-row { padding: 12px 16px; }

  .grid { gap: 6px; }
  .weekday { text-align: left; padding: 0 6px; font-size: 13px; }
  .weekday .short { display: none; }
  .weekday .long { display: inline; }

  .cell {
    height: auto;
    min-height: 76px;
    padding: 6px;
    align-items: stretch;
    justify-content: flex-start;
    gap: 3px;
  }

  .cell .date { font-size: 13px; line-height: 1.4; }
  .cell .mon-prefix { display: inline; }
  .cell.has-high .date { font-weight: 400; }
  .cell[aria-pressed='true'] .date { font-weight: 700; }
  .cell.closed .date { text-decoration: none; }
  .cell .dots { display: none; }
  .cell .chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .cell .closed-label { display: block; font-size: 12px; }

  .event-chip {
    display: block;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--market-soft);
    color: var(--text);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .event-chip.watch { background: color-mix(in srgb, var(--tick) 15%, transparent); }
  .event-chip.high { background: var(--market-strong); font-weight: 600; }
  .event-chip.watch.high { background: color-mix(in srgb, var(--tick) 35%, transparent); }
  .more { font-size: 12px; color: var(--muted); padding: 0 5px; }

  .selected-day { margin: 0 -24px; padding: 16px 24px 0; gap: 8px; }
  .selected-day h2 { font-size: 16px; }
}

/* ---------- Desktop ---------- */

@media (min-width: 1024px) {
  .site-header { padding: 6px 24px 6px 32px; }
  .signout { min-height: 36px; }

  .page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 32px;
    flex-direction: row;
    gap: 32px;
  }

  .sidebar {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .sidebar .check { min-height: 36px; }
  .sidebar .ticker-button { min-height: 36px; }

  .content { flex: 1 1 auto; gap: 24px; }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'title switch'
      'picker picker';
    gap: 24px 16px;
    padding: 0;
  }

  .chips-tablet { display: none; }
  .title { margin: 0; font-size: 26px; }
  .month-picker { justify-self: start; }

  .view-switch {
    display: flex;
    gap: 4px;
    padding: 0;
    background: transparent;
  }

  .view-switch button {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
  }

  .view-switch button[aria-pressed='true'] {
    border-color: var(--border-strong);
    background: var(--surface-raised);
    font-weight: 400;
  }

  .month-picker button { min-height: 40px; }

  .main { padding: 0; }

  .cell { min-height: 84px; padding: 8px; gap: 4px; }
  .event-chip { padding: 3px 6px; }

  .selected-day { margin: 0; padding: 0; border-top: 0; }
  .selected-day h2 { font-size: 14px; color: var(--muted); font-weight: 600; }
}

/* ---------- Header navigation and overview: tablet and desktop ---------- */

@media (min-width: 640px) {
  .site-header { flex-wrap: nowrap; }

  .site-nav {
    order: 0;
    flex: none;
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 0;
    background: transparent;
  }

  .site-nav a { min-height: 36px; padding: 0 12px; font-size: 14px; }
  .site-nav a:hover { color: var(--text); }
  .site-nav a[aria-current='page'] { background: var(--surface-raised); }

  .header-clock { display: inline; }
  .header-clock::after { content: ' · '; }

  .stripe { padding: 14px 0 12px; }
  .market-tabs,
  .quotes-scroll { padding: 0 24px; }
  .overview { padding: 20px 24px 32px; }
  .chart-panel { height: 480px; }
  .overview-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .market-tabs,
  .quotes-scroll { padding: 0 32px; }

  .overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    padding: 20px 32px 32px;
  }

  .chart-panel { height: clamp(420px, calc(100vh - 230px), 760px); }
  .overview-side { display: flex; }
  .quotes-frame { min-width: 0; }
}

/* ---------- Ticker page, news and journal ---------- */

.ticker-chips,
.journal-topics {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.ticker-chips::-webkit-scrollbar,
.journal-topics::-webkit-scrollbar { display: none; }

.ticker-chips { padding: 12px 16px 0; }

.ticker-chip,
.journal-topic {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.ticker-chip:hover,
.journal-topic:hover { color: var(--text); }

.ticker-chip[aria-current='page'],
.journal-topic[aria-current='page'] { border-color: transparent; background: var(--surface-raised); color: var(--text); }

.ticker-chip .swatch,
.news-tabs .swatch,
.journal-topic .swatch {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--tick);
}

.journal-topic .swatch.round { border-radius: 50%; }

.ticker-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.ticker-title { display: flex; flex-direction: column; gap: 2px; }

.ticker-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.ticker-name h1 { margin: 0; font-size: 26px; }
.ticker-name span { color: var(--muted); }
.ticker-quote { width: 220px; height: 72px; margin-left: -12px; }

.ticker-services { display: flex; flex-direction: column; gap: 8px; }
.services-label,
.preview-label { color: var(--muted); font-size: 12px; }

.services {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.service-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.service-link:hover { background: var(--surface); }
.service-link svg { width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 1.5; }

.ticker-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px 16px 32px;
}

.ticker-main,
.ticker-side { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.ticker-main { gap: 16px; }

.ticker-widgets { display: grid; gap: 16px; }

.widget-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #111113;
}

.widget-panel[hidden] { display: none; }
.widget-panel h2 { margin: 0; font-size: 15px; }
.widget-body { height: 440px; }
#technicals-body { height: 380px; }
.headlines { height: 520px; }

/* These widgets set their own container to 100% of its parent, so each sits in a box of fixed height. */
.widget-body > *,
.headlines > *,
.news-feed > * { height: 100%; }

.ticker-main .chart-panel { height: 360px; }

.ticker-event {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
}

.ticker-event .when { color: var(--muted); font-size: 13px; }
.ticker-event .today-title { font-weight: 600; }

.side-head { display: flex; justify-content: space-between; align-items: baseline; }
.side-head a { color: var(--focus); font-size: 14px; }

.journal-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
}

.journal-preview p { margin: 0 0 6px; color: var(--text-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.journal-preview p:last-child { margin-bottom: 0; }

.news-page { display: flex; flex-direction: column; gap: 24px; padding: 12px 0 32px; }
.news-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.news-tabs button { display: inline-flex; align-items: center; gap: 8px; }
.news-feed { height: max(520px, calc(100vh - 220px)); margin: 0 16px; }
.news-side { display: flex; flex-direction: column; gap: 24px; padding: 0 16px; }

.journal-page { display: flex; flex-direction: column; gap: 16px; padding: 12px 0 32px; }
.journal-topics { padding: 0 16px; }
.journal-topic-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.journal-topic-sub { display: none; color: var(--dim); font-size: 12px; font-weight: 400; }

.journal-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; padding: 0 16px; }

.journal-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.journal-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.journal-title h1 { margin: 0; font-size: 24px; }
.journal-title span,
.journal-head > a { color: var(--muted); }
.journal-head > a { font-size: 14px; }

.thesis-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
}

.thesis-top { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.thesis-top h2,
.notes h2 { margin: 0; font-size: 16px; }
.thesis-field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.thesis-field.half { grid-column: auto; }
.thesis-field p { margin: 0; color: var(--text-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.thesis-empty { grid-column: 1 / -1; }

/* 16px text keeps phones from zooming in when a field gets focus. */
.journal-main textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #111113;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}

.small-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
}

.small-button:hover { background: var(--surface-raised); }

.primary-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--ground);
  font-weight: 600;
}

.primary-button:disabled { opacity: 0.5; cursor: default; }

.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.form-error { grid-column: 1 / -1; margin: 0; color: var(--danger-text); }

.notes,
.note-form { display: flex; flex-direction: column; gap: 10px; }
.note-form { gap: 8px; }

.note-list { margin: 0; padding: 0; list-style: none; }

.note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid #1f1f23;
}

.note-top { display: flex; justify-content: space-between; align-items: center; }
.note time { color: var(--muted); font-size: 13px; }
.note p { margin: 0; color: var(--text-soft); white-space: pre-wrap; overflow-wrap: anywhere; }

.note-delete {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
}

.note-delete:hover { background: var(--surface); color: var(--danger-text); }

@media (min-width: 640px) {
  .ticker-chips { padding: 14px 24px 0; }

  .ticker-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    padding: 18px 24px;
  }

  .ticker-services { align-items: flex-end; }
  .services { display: flex; flex-wrap: wrap; justify-content: flex-end; }
  .service-link { min-height: 40px; }

  .ticker-grid { padding: 20px 24px 32px; }
  .ticker-main .chart-panel { height: 460px; }

  .news-page,
  .journal-page { padding-top: 20px; }
  .news-feed { margin: 0 24px; }
  .news-tabs,
  .news-side,
  .journal-topics,
  .journal-main { padding: 0 24px; }
  .news-side .services { justify-content: flex-start; }
}

@media (min-width: 1024px) {
  .ticker-chips { padding: 14px 32px 0; }
  .ticker-head { padding: 18px 32px; }

  .ticker-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    padding: 20px 32px 32px;
  }

  .news-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 32px;
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px 32px 32px;
  }

  .news-tabs,
  .news-side { padding: 0; }
  .news-feed { margin: 0; height: max(560px, calc(100vh - 180px)); }

  .journal-page {
    display: grid;
    grid-template-columns: 260px minmax(0, 760px);
    gap: 32px;
    padding: 20px 32px 32px;
  }

  .journal-topics { flex-direction: column; gap: 4px; padding: 0; overflow: visible; }

  .journal-topic {
    min-height: 56px;
    gap: 12px;
    border: 0;
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
  }

  .journal-topic[aria-current='page'] { background: var(--surface); }
  .journal-topic .swatch { width: 12px; height: 12px; border-radius: 3px; }
  .journal-topic-sub { display: block; }
  .journal-main { padding: 0; }
}
