/* Core Samples — "Core Log" direction. Design tokens from the handoff. */
:root {
  --page: #f7f6f2;
  --bar: #fbfaf7;
  --rail: #faf8f4;
  --surface: #fff;
  --ink: #1c1b18;
  --body: #2c2a25;
  --muted: #9a938a;
  --muted2: #a49c90;
  --secondary: #5f574c;
  --disabled: #c7bfb2;
  --border: #e6e1d6;
  --border2: #e2ddd2;
  --selected: #efeadf;
  --green: #6ea043;
  --green-bright: #8fbf6a;
  --pdf: #d9534f;
  --code-fn: #2c6e49;
  --code-kw: #a05a2c;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: #4f7233; }
a:hover { color: #3c5726; }
button { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; background: var(--bar);
  border-bottom: 1px solid var(--border);
}
.logo {
  width: 22px; height: 22px; border-radius: 5px; background: var(--ink);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.logo > span { width: 9px; height: 9px; border-radius: 2px; background: var(--green-bright); }
.wordmark { font: 600 14px/1 var(--sans); letter-spacing: -.01em; }
.tagline { font: 400 12px/1 var(--mono); color: var(--muted); }
@media (max-width: 560px) { .tagline { display: none; } }
.spacer { flex: 1; }

.btn {
  font: 500 12px/1 var(--mono); border-radius: 6px; cursor: pointer;
  padding: 8px 12px; border: 1px solid var(--border); background: var(--surface); color: var(--secondary);
  transition: background .14s ease, box-shadow .14s ease, transform .05s ease;
}
.btn:hover { background: var(--selected); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn-primary:hover { background: #2c2a26; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--secondary); }
.btn-ghost:hover { background: var(--selected); }

/* user chip in bar */
.userchip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.userchip:hover { background: var(--selected); }
.userchip .name { font: 600 12px/1 var(--sans); }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.28);
  min-width: 170px; padding: 6px; z-index: 30;
}
.menu-pop button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; font: 500 12px/1.2 var(--sans); color: var(--body); cursor: pointer; }
.menu-pop button:hover { background: var(--selected); }

/* ---------- Avatars ---------- */
.avatar { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; font: 600 11px/1 var(--sans); }
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }
.av-green  { background: #e4ecd9; color: #4f7233; }
.av-blue   { background: #dbe4ec; color: #37536b; }
.av-amber  { background: #f0e6cf; color: #8a6a2c; }
.av-violet { background: #e6ddef; color: #5b4a7a; }
.av-rose   { background: #f0dbe0; color: #97405a; }
.av-slate  { background: #e2e4e7; color: #4a545f; }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: flex-start; max-width: 1080px; margin: 0 auto; }
.rail {
  position: sticky; top: 50px; align-self: flex-start;
  width: 190px; flex: none; padding: 22px 0 40px; background: transparent;
  max-height: calc(100vh - 50px); overflow: auto;
}
.rail-label { font: 500 10px/1 var(--mono); letter-spacing: .14em; color: var(--muted2); text-transform: uppercase; padding: 0 20px 12px; }
.rail-item {
  display: flex; justify-content: space-between; align-items: center;
  font: 500 12px/1 var(--mono); color: var(--secondary);
  padding: 9px 20px; cursor: pointer; border-left: 2px solid transparent;
  transition: background .14s ease;
}
.rail-item:hover { background: var(--selected); }
.rail-item.active { font-weight: 600; color: var(--ink); background: var(--selected); border-left-color: var(--green); }
.rail-item.locked { color: var(--disabled); }
.rail-item .count { color: var(--green-bright); }

.feed { flex: 1; min-width: 0; padding: 22px 26px 120px; }

/* ---------- Week sections ---------- */
.week-sec { scroll-margin-top: 64px; margin-bottom: 40px; }
.week-head { font: 600 22px/1.15 var(--sans); letter-spacing: -.02em; margin: 0 0 4px; }
.week-sub { font: 400 12px/1.4 var(--mono); color: var(--muted); margin-bottom: 20px; }
.week-empty { border: 1px dashed var(--border2); border-radius: 9px; padding: 22px; text-align: center; font: 400 13px/1.5 var(--mono); color: var(--muted); background: #fcfbf8; }

/* editable week title */
.week-topic.editable { cursor: text; border-bottom: 1px dashed transparent; }
.week-topic.editable:hover { border-bottom-color: var(--green); }
.week-topic-input { font: 600 22px/1.15 var(--sans); letter-spacing: -.02em; color: var(--ink); border: 1px solid var(--green); border-radius: 6px; padding: 1px 6px; background: #fff; outline: none; }

/* per-week compose button */
.week-add {
  display: block; width: 100%; text-align: left; margin-top: 4px;
  font: 500 12px/1 var(--mono); color: var(--secondary);
  background: transparent; border: 1px dashed var(--border2); border-radius: 8px;
  padding: 11px 14px; cursor: pointer; transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.week-add:hover { background: var(--selected); border-color: var(--green); color: var(--ink); }
.week-add[disabled] { opacity: .55; cursor: default; }
.week-add[disabled]:hover { background: transparent; border-color: var(--border2); color: var(--secondary); }

/* editable tagline */
.tagline.editable { cursor: text; }
.tagline.editable:hover { color: var(--secondary); text-decoration: underline dotted; }
.tagline-input { font: 400 12px/1 var(--mono); color: var(--ink); border: 1px solid var(--green); border-radius: 5px; padding: 3px 6px; background: #fff; outline: none; min-width: 220px; }

/* floating jump-to-bottom */
.jump-btn {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--ink); background: var(--ink); color: var(--page);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 6px 20px -6px rgba(0,0,0,.45); transition: transform .12s ease, opacity .2s ease;
}
.jump-btn:hover { transform: translateY(-1px); background: #2c2a26; }

/* ---------- Entry card ---------- */
.entry {
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  padding: 18px 18px 16px; margin-bottom: 16px; scroll-margin-top: 68px;
  transition: box-shadow .16s ease, border-color .16s ease;
}
.entry:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.entry.flash { box-shadow: 0 0 0 2px var(--green); border-color: var(--green); }
.entry-head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.entry-name { font: 600 13px/1 var(--sans); }
.entry-time { font: 400 11px/1 var(--mono); color: var(--muted2); }
.entry-edited { font: 400 10px/1 var(--mono); color: var(--disabled); }
.tag-inst { font: 500 9px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #4f7233; background: #e4ecd9; padding: 3px 5px; border-radius: 4px; }
.entry-body { font: 400 14px/1.6 var(--sans); color: var(--body); word-wrap: break-word; }
.entry-body p { margin: 0 0 10px; }
.entry-body ul, .entry-body ol { margin: 8px 0; padding-left: 22px; }
.entry-body code { font-family: var(--mono); font-size: .92em; background: #f0ece2; padding: 1px 5px; border-radius: 4px; }
.entry-body pre { background: #fbfaf7; border: 1px solid var(--border); border-radius: 7px; padding: 11px 13px; overflow: auto; }
.entry-actions { display: flex; gap: 4px; margin-top: 12px; opacity: 0; transition: opacity .14s ease; }
.entry:hover .entry-actions, .entry:focus-within .entry-actions { opacity: 1; }
.entry-actions .btn { padding: 5px 9px; font-size: 11px; }

/* ---------- Attachments ---------- */
.att-image { position: relative; margin-top: 13px; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.att-image img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #f3f0e9; cursor: zoom-in; }
.att-image .fname { position: absolute; left: 9px; bottom: 9px; font: 400 11px/1 var(--mono); color: #7d7568; background: #fff; padding: 3px 6px; border-radius: 4px; }
.att-video { position: relative; margin-top: 13px; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: #000; }
.att-video-el { display: block; width: 100%; max-height: 480px; background: #000; }
.att-video .fname { position: absolute; left: 9px; top: 9px; font: 400 11px/1 var(--mono); color: #7d7568; background: rgba(255,255,255,.9); padding: 3px 6px; border-radius: 4px; pointer-events: none; }
.att-code { margin-top: 11px; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.att-code .strip { display: flex; justify-content: space-between; align-items: center; font: 400 10.5px/1 var(--mono); color: var(--muted); background: #f3f0e9; border-bottom: 1px solid var(--border); padding: 7px 11px; }
.att-code .strip button { border: 0; background: transparent; font: 400 10.5px/1 var(--mono); color: var(--secondary); cursor: pointer; }
.att-code pre { margin: 0; font: 400 12px/1.65 var(--mono); background: #fbfaf7; padding: 11px 13px; overflow: auto; max-height: 360px; }
.att-file { margin-top: 11px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; background: var(--surface); text-decoration: none; color: var(--secondary); }
.att-file:hover { background: var(--selected); }
.att-file .glyph { width: 14px; height: 17px; border-radius: 2px; flex: none; background: var(--pdf); }
.att-file .glyph.code { background: #4f7233; }
.att-file .glyph.other { background: #8a94a0; }
.att-file .fname { font: 400 12px/1 var(--mono); }

/* ---------- Modals ---------- */
.scrim { position: fixed; inset: 0; background: rgba(28,27,24,.34); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 40px 22px; overflow: auto; }
.panel { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border2); border-radius: 11px; box-shadow: 0 20px 50px -12px rgba(0,0,0,.4); display: flex; flex-direction: column; max-height: calc(100vh - 80px); overflow: hidden; animation: rise .3s ease; }
.panel.sm { max-width: 400px; }
/* Inline composer: a normal in-flow panel, not a floating popover. */
.panel.inline {
  max-width: none; width: 100%; max-height: none; overflow: visible;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); animation: none; margin-bottom: 24px;
}
.panel.inline .panel-body { overflow: visible; }
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #eee7db; }
.panel-title { font: 600 14px/1 var(--sans); }
.panel-sub { font: 400 11px/1 var(--mono); color: var(--muted2); }
.panel-body { flex: 1; overflow: auto; padding: 16px; }
.panel-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid #eee7db; background: var(--bar); }
.panel-foot .note { flex: 1; font: 400 11px/1.3 var(--mono); color: var(--disabled); }
.close-x { width: 26px; height: 26px; border: 0; background: #f3f0e9; border-radius: 6px; color: #7d7568; font: 400 15px/1 var(--mono); cursor: pointer; }
select.week-select { font: 500 11px/1 var(--mono); color: var(--ink); background: #f3f0e9; border: 1px solid var(--border); border-radius: 5px; padding: 6px 7px; cursor: pointer; }

/* composer toolbar + editor */
.toolbar { display: flex; align-items: center; gap: 4px; padding: 8px 14px; border-bottom: 1px solid #f0ece2; background: var(--bar); }
.tbtn { height: 26px; min-width: 28px; padding: 0 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 5px; color: var(--secondary); cursor: pointer; font: 500 12px/1 var(--mono); }
.tbtn:hover { background: var(--selected); }
.tbtn.b { font: 700 13px/1 var(--sans); }
.tbtn.i { font: italic 500 13px/1 var(--sans); }
.editor { min-height: 120px; font: 400 14px/1.6 var(--sans); color: var(--body); outline: none; }
.editor:empty:before { content: attr(data-placeholder); color: #b3aca0; }
.editor code { font-family: var(--mono); font-size: .92em; background: #f0ece2; padding: 1px 5px; border-radius: 4px; }
.editor ul { margin: 8px 0; padding-left: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px 6px 6px; background: var(--rail); }
.chip img { width: 26px; height: 26px; border-radius: 4px; object-fit: cover; }
.chip .g { width: 20px; height: 24px; border-radius: 3px; flex: none; }
.chip .fname { font: 400 12px/1 var(--mono); color: var(--secondary); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .rm { border: 0; background: transparent; color: var(--muted); cursor: pointer; font: 400 13px/1 var(--mono); }
.dropzone { display: block; margin-top: 14px; border: 1.5px dashed #d8d0c2; border-radius: 8px; padding: 16px; background: #fcfbf8; text-align: center; font: 400 12px/1.4 var(--mono); color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--green); background: #f3f7ee; }

.field { display: block; margin-bottom: 12px; }
.field label { display: block; font: 500 11px/1 var(--mono); color: var(--secondary); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.field input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; font: 400 14px/1.4 var(--sans); color: var(--ink); background: #fcfbf8; }
.field input:focus { outline: none; border-color: var(--green); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--ink); }
.notice { font: 400 12px/1.5 var(--mono); color: var(--secondary); background: var(--rail); border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; margin-top: 12px; word-break: break-all; }
.err { color: var(--pdf); font: 400 12px/1.4 var(--mono); margin-top: 8px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(20,19,17,.82); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); font: 500 12px/1 var(--mono); padding: 10px 14px; border-radius: 7px; z-index: 70; opacity: 0; transition: opacity .2s ease; }
.toast.show { opacity: 1; }

/* ---------- Responsive: rail becomes a horizontal scroller ---------- */
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .rail {
    position: sticky; top: 50px; width: 100%; max-height: none;
    display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px;
    background: var(--bar); border-bottom: 1px solid var(--border); z-index: 15;
  }
  .rail-label { display: none; }
  .rail-item { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; border-radius: 6px; padding: 8px 12px; }
  .rail-item.active { border-left: 0; border-bottom-color: var(--green); }
  .feed { padding: 18px 16px 100px; width: 100%; }
}
