/*
 * Daily Log — application styles (vanilla CSS).
 * Lexxy editor theming lives at the bottom of this file; base Lexxy rules ship in the lexxy gem's stylesheet.
 */

:root {
  --paper:        #faf8f3;
  --surface:      #ffffff;
  --surface-2:    #f4f1ea;
  --ink:          #23251f;
  --ink-soft:     #54564d;
  --muted:        #8c8e82;
  --line:         #e8e3d7;
  --line-strong:  #d9d3c4;
  --accent:       #2b8acb;
  --accent-deep:  #1c6499;
  --accent-tint:  #e8f1fb;
  --danger:       #b4453a;

  --radius:       14px;
  --radius-sm:    10px;
  --shadow-sm:    0 1px 2px rgba(35, 37, 31, 0.04), 0 1px 3px rgba(35, 37, 31, 0.06);
  --shadow-md:    0 6px 24px rgba(35, 37, 31, 0.08), 0 2px 6px rgba(35, 37, 31, 0.05);

  --font-ui:      "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-read:    "Newsreader", Georgia, serif;

  --nav-h:        66px;
  --maxw:         1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 480px at 78% -8%, rgba(43, 138, 203, 0.06), transparent 60%);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Navbar ---------- */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--nav-h);
  padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(250, 248, 243, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-sm);
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.navbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  flex: 0 0 auto;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn--flash {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Flash ---------- */

.flash {
  max-width: var(--maxw);
  margin: 16px auto -8px;
  padding: 11px 16px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  border: 1px solid #c3ddf2;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  width: calc(100% - clamp(32px, 8vw, 80px));
}

/* ---------- Page layout ---------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 38px) clamp(16px, 4vw, 40px) 64px;
}

.layout {
  display: flex;
  align-items: flex-start;
  gap: clamp(20px, 3vw, 34px);
}

/* ---------- Sidebar / week nav ---------- */

.sidebar {
  flex: 0 0 286px;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}

.week {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.week__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.week__range {
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

.week__arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.week__arrow:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.week__days {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--ink-soft);
  transition: background 0.14s ease, color 0.14s ease;
}

.day:hover { background: var(--surface-2); color: var(--ink); }

.day__name {
  flex: 1;
  font-weight: 500;
  font-size: 0.95rem;
}

.day__date {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.day__flag {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  flex: 0 0 auto;
}

.day--filled .day__flag { background: var(--accent); }

.day--today .day__name::after {
  content: "Today";
  margin-left: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  vertical-align: middle;
}

.day--selected {
  background: var(--accent-tint);
  border-color: #c3ddf2;
  color: var(--accent-deep);
  box-shadow: inset 3px 0 0 var(--accent);
}

.day--selected .day__name { font-weight: 600; }
.day--selected .day__date { color: var(--accent-deep); }
.day--selected:hover { background: var(--accent-tint); }

.week__today {
  display: block;
  margin-top: 12px;
  padding: 9px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-deep);
  border: 1px dashed #b6d3ef;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.week__today:hover { background: var(--accent-tint); }

/* ---------- Editor ---------- */

.editor {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Fill the viewport below the navbar so the editor + Save button reach the
     bottom of the browser by default. */
  min-height: calc(100dvh - var(--nav-h) - 7rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(22px, 3.4vw, 40px);
}

.entry-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.editor__head {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.editor__eyebrow {
  margin: 0 0 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.editor__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.editor__sub {
  margin: 8px 0 0;
  font-size: 1rem;
  color: var(--ink-soft);
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  vertical-align: middle;
}

.editor__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

/* In the edit form, keep Cancel/Save pinned to the bottom of the viewport while
   scrolling. Negative margins let the bar span the editor's padding so it reads
   as a footer hugging the card edges. */
.entry-form .editor__actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 22px clamp(-40px, -3.4vw, -22px) clamp(-40px, -3.4vw, -22px);
  padding: 16px clamp(22px, 3.4vw, 40px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* Read-only rendered entry. Grows to fill the panel so the actions row sits at
   the bottom, mirroring the editor form's flex layout. */
.entry-read {
  flex: 1 1 auto;
  min-height: 0;
}

.entry-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

/* Plain-text note — edit form field. Stacks a small-caps label over a
   full-width textarea, separated from the rich-text body above. */
.entry-note {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.entry-note__label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.entry-note__field {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  padding: 12px 14px;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.entry-note__field--tall { min-height: 500px; }

.entry-note__field::placeholder { color: var(--muted); }

.entry-note__field:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Read-only note — shown as a tinted card below the entry body. */
.note-card {
  position: relative;
  margin-top: 24px;
  padding: 18px 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* Copy-to-clipboard button tucked into the card's top-right corner. */
.note-card__copy {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  box-shadow: none;
  opacity: 0.4;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.note-card:hover .note-card__copy,
.note-card__copy:focus-visible {
  opacity: 1;
}

/* The main entry body — the primary card. Grows to fill the panel so the
   actions row sits at the bottom, and reads a touch larger than the meta cards. */
.note-card--body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  background: var(--surface);
}

.note-card--body .note-card__body {
  font-size: 1.1rem;
}

.note-card__label {
  margin: 0 0 8px;
  padding-right: 38px;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.note-card__body {
  font-family: var(--font-read);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.note-card__body p { margin: 0 0 0.8em; }
.note-card__body p:last-child { margin-bottom: 0; }

.btn {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover { box-shadow: var(--shadow-md); }

/* ---------- Mobile day dropdown (hidden on desktop) ---------- */

.day-menu { display: none; position: relative; }

.day-menu__summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 62vw;
  padding: 9px 14px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  white-space: nowrap;
}

.day-menu__summary::-webkit-details-marker { display: none; }
.day-menu__label { overflow: hidden; text-overflow: ellipsis; }
.day-menu__chevron { color: var(--muted); transition: transform 0.18s ease; flex: 0 0 auto; }
.day-menu[open] .day-menu__chevron { transform: rotate(180deg); }

.day-menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 88vw);
  z-index: 60;
  animation: menu-in 0.16s ease;
}

.day-menu__panel .week {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .sidebar { display: none; }
  .day-menu { display: block; }
  .layout { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Lexxy editor theming ---------- */

/* Remap Lexxy's design tokens onto the app palette. Lexxy's own rules use
   :where() (zero specificity), so these variable overrides drive both the live
   editor and rendered .lexxy-content without needing per-element overrides. */
:root {
  --lexxy-color-ink:            var(--ink);
  --lexxy-color-ink-medium:     var(--ink-soft);
  --lexxy-color-ink-light:      var(--muted);
  --lexxy-color-ink-lighter:    var(--line-strong);  /* borders / separators */
  --lexxy-color-ink-lightest:   var(--surface-2);    /* button hover */

  --lexxy-color-accent-dark:    var(--accent-deep);
  --lexxy-color-accent-medium:  var(--accent);
  --lexxy-color-accent-light:   #c3ddf2;
  --lexxy-color-accent-lightest: var(--accent-tint); /* active button / selection */

  --lexxy-color-canvas:         var(--surface);
  --lexxy-color-link:           var(--accent-deep);

  --lexxy-font-base:            var(--font-read);
  --lexxy-radius:               7px;
  --lexxy-shadow:               var(--shadow-md);
  --lexxy-focus-ring-color:     var(--accent);
}

/* Let the editor fill the panel like the old Trix one did. */
lexxy-editor {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* A single, clean focus ring on the whole editor (toolbar + content). */
lexxy-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 138, 203, 0.15);
}

.lexxy-editor__content {
  flex: 1 1 auto;
  min-height: 220px;
  font-size: 1.12rem;
}

/* Suppress the inner contenteditable focus box so the editor shows only the
   outer ring above — not a second, square-cornered outline around the text. */
.lexxy-editor__content:focus,
.lexxy-editor__content:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Keep the formatting toolbar in view as the entry grows and the page scrolls. */
lexxy-toolbar {
  position: sticky;
  top: var(--nav-h);
  z-index: 10;
  background: var(--surface);
  border-start-start-radius: inherit;
  border-start-end-radius: inherit;
}

/* Rendered + editing content typography. */
.lexxy-content {
  font-family: var(--font-read);
  line-height: 1.75;
  color: var(--ink);
}

.lexxy-content :is(h1, h2, h3) { font-family: var(--font-display); }

/* ---------- Flash variants ---------- */

.flash--alert {
  background: #fbecea;
  color: var(--danger);
  border-color: #f0cfca;
}

/* ---------- Account menu (navbar) ---------- */

.account { position: relative; }
.account > summary { list-style: none; cursor: pointer; }
.account > summary::-webkit-details-marker { display: none; }

.account__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.account__email {
  margin: 0 0 12px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.account__signout button,
.account__signout {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

.account__signout button:hover { background: var(--paper); }

/* ---------- Auth (sign-in / verify) ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--nav-h) - 80px);
  padding: 40px 20px;
}

.auth__card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.auth__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
}

.auth__lead {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

.auth__form { display: flex; flex-direction: column; gap: 8px; }

.auth__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.auth__input {
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 138, 203, 0.15);
}

.auth__input--code {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth__submit { margin-top: 10px; }

.auth__resend { margin-top: 18px; }

.auth__linkbtn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-deep);
  cursor: pointer;
}

.auth__linkbtn:hover { text-decoration: underline; }

.auth__alt {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth__alt:hover { color: var(--ink-soft); }

/* ---------- Navbar primary links ---------- */

.navbar__left {
  display: inline-flex;
  align-items: center;
  gap: clamp(14px, 3vw, 30px);
  min-width: 0;
}

.nav-menu {
  position: relative;
  display: inline-flex;
}

.nav-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-menu__trigger:hover { background: var(--surface-2); color: var(--ink); }

.nav-menu__chevron {
  transition: transform 0.15s ease;
}

.nav-menu__trigger[aria-expanded="true"] .nav-menu__chevron {
  transform: rotate(180deg);
}

.nav-menu__list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.nav-menu__list[hidden] { display: none; }

.nav-menu__item {
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-menu__item:hover { background: var(--surface-2); color: var(--ink); }

.nav-menu__item--active {
  color: var(--accent-deep);
  background: var(--accent-tint);
}

/* ---------- Links page ---------- */

.links-page { max-width: 760px; margin: 0 auto; }

.links-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.links-head__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  letter-spacing: -0.02em;
}

.links-head__sub { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.96rem; }

.links-head__add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  flex: 0 0 auto;
}

.links-empty {
  margin: 40px 0;
  text-align: center;
  color: var(--muted);
}

.collections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.collection {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}

.collection__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.collection__title-frame { flex: 1 1 auto; min-width: 0; }

.collection__title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.collection__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.collection__add-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  font-size: 0.85rem;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 8px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background 0.14s ease;
}

.link-row:hover { background: var(--surface-2); }

.link-row__link {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  color: var(--accent-deep);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row__link:hover { text-decoration: underline; }

.link-row__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.link-row:hover .link-row__actions,
.link-row:focus-within .link-row__actions { opacity: 1; }

/* Task-link rows surface their actions (Open + overflow menu) permanently —
   an open menu must never be hidden by the hover-reveal used on the Links page. */
.task-link__actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.link-row--editing {
  display: block;
  background: var(--surface-2);
}

/* ---------- Row overflow menu (kebab) ---------- */

.row-menu { position: relative; display: inline-flex; }

.row-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.row-menu__trigger:hover,
.row-menu__trigger[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }

.row-menu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* Open upward — used inside media cards where the menu sits near the bottom. */
.row-menu__list--up { top: auto; bottom: calc(100% + 6px); }

.row-menu__list[hidden] { display: none; }

/* Both link_to items and button_to forms live in the menu — normalise them. */
.row-menu__form { margin: 0; }

.row-menu__item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.row-menu__item:hover { background: var(--surface-2); color: var(--ink); }

.row-menu__item--danger { color: var(--danger, #c0362c); }
.row-menu__item--danger:hover { background: var(--danger-tint, #fbeae8); color: var(--danger, #c0362c); }

/* Stacked link form: title row, url row, then the buttons — full width so it
   stays usable on narrow screens. */
.link-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

/* turbo-frame defaults to display:inline, which would shrink the stacked form to
   its content width — make the new-link frame fill the card. */
.new-link-frame { display: block; }

/* Override .inline-form__input's `flex: 1 1 160px` (defined later in this file):
   in a column flex that 160px basis becomes the input HEIGHT. The descendant
   selector raises specificity so this wins regardless of source order. */
.link-form .link-form__field {
  flex: 0 0 auto;
  width: 100%;
}

.link-form__actions {
  display: flex;
  gap: 8px;
}

.link-form__error {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

/* ---------- Inline edit forms ---------- */

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.inline-form__input {
  flex: 1 1 160px;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inline-form__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 138, 203, 0.15);
}

.inline-form__input--url { flex: 2 1 220px; }

.btn--sm { padding: 8px 14px; font-size: 0.88rem; }

.btn--ghost {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}

.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--danger {
  color: #fff;
  background: var(--danger);
}

.btn--danger:hover { filter: brightness(0.94); }

/* ---------- Icon buttons & drag handles ---------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn--danger:hover { color: var(--danger); border-color: #f0cfca; background: #fbecea; }

.drag-handle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.drag-handle:active { cursor: grabbing; }

.sortable-ghost { opacity: 0.4; }
.sortable-chosen { background: var(--accent-tint); border-radius: var(--radius-sm); }
.sortable-drag { box-shadow: var(--shadow-md); }

/* ---------- Confirm dialog ---------- */

.confirm-dialog {
  margin: auto;
  max-width: 380px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background: var(--surface);
  color: var(--ink);
}

.confirm-dialog::backdrop { background: rgba(35, 37, 31, 0.32); }

.confirm-dialog__message {
  margin: 0 0 20px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Tasks ---------- */

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.task-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.task-card:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.task-card--done { opacity: 0.62; }

.task-card__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task-card__title { font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.task-card__meta { color: var(--muted); font-size: 0.85rem; }

.status-badge {
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.status-badge--open        { color: var(--accent-deep); background: var(--accent-tint); }
.status-badge--in_progress { color: #8a5a00; background: #fbf0d8; }
.status-badge--done        { color: var(--muted); background: var(--surface-2); }

/* Task show */
.task-head { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.task-head__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.task-head__back { color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; }
.task-head__back:hover { color: var(--accent-deep); }
.task-head__title {
  position: sticky;
  top: var(--nav-h);
  z-index: 10;
  margin: 0 0 12px;
  padding: 8px 0;
  background: var(--paper);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
}
.task-head__actions { display: flex; gap: 8px; }

.task-description {
  margin: 0 0 28px;
  font-family: var(--font-read);
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.task-description p { margin: 0 0 0.8em; }

.task-section { margin: 0 0 32px; }
.task-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.task-section__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
}
.task-section__add { display: flex; gap: 6px; flex-wrap: wrap; }

/* Link rows */
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.link-list--archived { opacity: 0.7; }
.task-link__kind {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 3px 8px;
}
.task-link--archived .link-row__link { color: var(--muted); text-decoration: line-through; }

/* Media cards */
.media-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.media-grid--archived { opacity: 0.8; }
.media-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-card--archived { background: var(--surface-2); }
.media-card__head { display: flex; align-items: center; gap: 8px; }
.media-card__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card__collapse {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted, #666);
  cursor: pointer;
}
.media-card__collapse:hover { background: var(--surface-2); }
.media-card__collapse svg { transition: transform 0.15s ease; }
.media-card--collapsed .media-card__collapse svg { transform: rotate(-90deg); }
.media-card--collapsed .media-card__preview { display: none; }
.media-card__preview { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.media-card__frame { display: block; width: 100%; height: 440px; min-height: 220px; border: 0; background: #fff; resize: vertical; }
.media-card__video { display: block; width: 100%; max-height: 240px; background: #000; }
.media-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.media-card__actions .row-menu { margin-left: auto; }

/* Archive disclosure */
.archive { margin-top: 14px; }
.archive__summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; padding: 6px 0; }
.archive__summary:hover { color: var(--accent-deep); }

/* Forms */
.task-form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.task-form__label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.92rem; color: var(--ink-soft); }
/* Reset .inline-form__input's `flex: 1 1 160px`: inside the column-flex label that
   160px basis becomes the field HEIGHT, stretching inputs into tall boxes. */
.task-form__field { flex: 0 0 auto; width: 100%; }
.task-form__hint { font-weight: 400; color: var(--muted); }
textarea.task-form__field { resize: vertical; font-family: var(--font-ui); line-height: 1.5; }

/* Profile / token */
.token-row { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.token-row__input { flex: 1 1 auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }

/* API docs */
.api-docs pre {
  background: var(--ink);
  color: #f4f1ea;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.api-docs code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.api-docs p code, .api-docs li code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 0.88em; }
.api-docs__ep { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; margin: 18px 0 6px; color: var(--accent-deep); }
.api-docs__list { line-height: 1.6; color: var(--ink-soft); }

/* Bosses — vertical boss timeline ---------------------------------------- */
.boss-page { max-width: 860px; margin: 0 auto; }

.boss-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 18px 0 28px; padding: 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.boss-form__name {
  flex: 1 1 170px; padding: 9px 12px; font: inherit;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
.boss-form__range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.boss-form__lead { color: var(--muted); font-size: 0.9rem; }
.boss-form__sel {
  padding: 8px 8px; font: inherit; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px;
}

.boss-tl {
  display: grid;
  grid-template-columns: 150px repeat(var(--lanes), minmax(0, 1fr));
  grid-auto-rows: 34px;
  column-gap: 10px;
  position: relative;
}
.boss-tl::before {
  content: ""; position: absolute; left: 150px; top: 0; bottom: 0;
  width: 2px; background: var(--line-strong);
}
.boss-tl__lbl {
  grid-column: 1; display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding-right: 14px; font-size: 0.8rem; color: var(--muted);
  border-top: 1px solid var(--line);
}
.boss-tl__lbl.is-month { color: var(--ink); font-weight: 600; border-top: 2px solid var(--line-strong); }
.boss-tl__lbl.is-today { color: var(--accent-deep); font-weight: 700; }

.boss-tag {
  display: inline-block; border-radius: 999px; padding: 1px 7px;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em;
}
.boss-tag--today { background: var(--accent); color: #fff; }
.boss-tag--start { background: var(--surface); color: var(--muted); border: 1px solid var(--line-strong); }

.boss-bar {
  position: relative; margin: 2px 4px; padding: 6px 9px; border-radius: 10px;
  display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  box-shadow: var(--shadow-sm); font-size: 0.78rem; line-height: 1.25;
}
.boss-bar__name { font-weight: 700; padding-right: 40px; }
.boss-bar__range { font-size: 0.68rem; opacity: 0.82; }
.boss-bar.is-editing { outline: 2px solid var(--accent); outline-offset: 1px; }

.boss-bar__actions {
  position: absolute; top: 3px; right: 3px; display: flex; gap: 3px;
  opacity: 0; transition: opacity 0.12s ease;
}
.boss-bar:hover .boss-bar__actions,
.boss-bar.is-editing .boss-bar__actions { opacity: 1; }
.boss-bar__actform { margin: 0; }
.boss-bar__act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; border: 0; cursor: pointer;
  border-radius: 6px; background: rgba(255, 255, 255, 0.6); color: inherit;
  line-height: 1;
}
.boss-bar__act:hover { background: var(--accent); color: #fff; }
.boss-bar__act--del:hover { background: var(--danger); color: #fff; }

/* Lane colours — cycle through six tints. */
.boss-bar--l0 { background: #e8f1fb; color: #1c6499; border: 1px solid #c6def4; }
.boss-bar--l1 { background: #fbeee8; color: #9b4f2e; border: 1px solid #f3d5c6; }
.boss-bar--l2 { background: #e8f7ef; color: #2c7a52; border: 1px solid #c6ebd6; }
.boss-bar--l3 { background: #f3e8fb; color: #6b3a9b; border: 1px solid #e0c6f4; }
.boss-bar--l4 { background: #fbf6e0; color: #8a6d1c; border: 1px solid #f0e4b0; }
.boss-bar--l5 { background: #e6f3f5; color: #1f6b78; border: 1px solid #c2e3e8; }
