/* ============================================================
   MARGIN · components
   Square geometry · hairline borders · no decorative shadows
   ============================================================ */

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
              color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover { background: var(--panel-3); border-color: var(--muted); }
.btn:active { transform: translateY(.5px); background: var(--panel-2); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn .icon { width: 14px; height: 14px; }

.btn--primary {
  background: var(--pine);
  border-color: var(--pine);
  color: #f2f5f0;
}
.btn--primary:hover { background: var(--pine-600); border-color: var(--pine-600); }
.btn--primary:active { background: var(--pine-700); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}
.btn--ghost:hover { background: var(--panel); border-color: var(--line-strong); color: var(--ink); }

.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 6px;
  height: 26px;
}
.btn--quiet:hover { background: var(--panel-2); color: var(--ink); border-color: transparent; }

.btn--danger { color: var(--brick); }
.btn--danger:hover { background: var(--brick-bg); border-color: var(--brick-line); }

.btn--mini {
  height: 24px;
  padding: 0 9px;
  font-size: 11.5px;
  border-color: var(--line);
  background: transparent;
  color: var(--ink-soft);
}
.btn--mini:hover { background: var(--panel-3); border-color: var(--line-strong); color: var(--ink); }
.btn--mini.is-on {
  border-color: var(--st-a-line);
  background: var(--st-a-bg);
  color: var(--st-a);
}
.btn--mini[disabled] { opacity: .4; }

.btn--lg { height: 40px; padding: 0 20px; font-size: 13.5px; }
.btn--block { width: 100%; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--r-1);
  color: var(--muted);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.icon-btn:hover { background: var(--panel-3); color: var(--ink); }
.icon-btn .icon { width: 16px; height: 16px; }

.link {
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.link:hover { color: var(--pine); border-color: var(--pine); }

.link-quiet {
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.link-quiet:hover { color: var(--ink); border-bottom-color: var(--line-strong); }

/* ---------------- segmented control ---------------- */

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--r-1);
  overflow: hidden;
}
.seg__btn {
  padding: 0 12px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
  white-space: nowrap;
}
.seg__btn + .seg__btn { border-left: 1px solid var(--line); }
.seg__btn:hover { color: var(--ink); background: var(--panel-2); }
.seg__btn.is-on { background: var(--panel-3); color: var(--ink); font-weight: 500; }
.seg__btn:active { background: var(--paper-deep); }

/* ---------------- tabs (underline) ---------------- */

.tabs { display: flex; align-items: center; gap: 24px; }
.tabs__btn {
  position: relative;
  padding: 0 0 11px;
  font-size: 13px;
  color: var(--muted);
  transition: color var(--dur-2) var(--ease);
}
.tabs__btn::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-3) var(--ease);
}
.tabs__btn:hover { color: var(--ink); }
.tabs__btn.is-on { color: var(--ink); font-weight: 500; }
.tabs__btn.is-on::after { transform: scaleX(1); }
.tabs__count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  margin-left: 6px;
}

/* ---------------- chips ---------------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 26px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: transparent;
  font-size: 11.5px;
  color: var(--muted);
  transition: all var(--dur-2) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); background: var(--panel); }
.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 500;
}
.chip__dot {
  width: 5px; height: 5px;
  background: currentColor;
  opacity: .55;
}

/* ---------------- tags / stamps ---------------- */

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: .02em;
  white-space: nowrap;
}
.tag--w { border-color: var(--line-strong); color: var(--ink-soft); }

/* state stamp: the marginal letter system */
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-soft);
  background: transparent;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.stamp--a { color: var(--st-a); border-color: var(--st-a-line); background: var(--st-a-bg); }
.stamp--u { color: var(--faint); border-color: var(--line-strong); background: var(--panel-warm); }
.stamp--b { color: var(--st-b); border-color: var(--st-b-line); background: var(--st-b-bg); }
.stamp--c { color: var(--st-c); border-color: var(--st-c-line); background: var(--st-c-bg); }
.stamp--lg { width: 30px; height: 30px; font-size: 17px; }

.state-word {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.state-word--a { color: var(--st-a); }
.state-word--b { color: var(--st-b); }
.state-word--c { color: var(--st-c); }

.stamp-flash { animation: stampflash 520ms var(--ease); }
@keyframes stampflash {
  0% { transform: scale(.82); opacity: .2; }
  45% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------------- form fields ---------------- */

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-size: 11.5px;
  letter-spacing: .03em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.field__hint { font-size: 11px; color: var(--faint); line-height: 1.55; }
.field__error { font-size: 11.5px; color: var(--brick); }

.input, .textarea, .select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  color: var(--ink);
  font-size: 13px;
  padding: 8px 10px;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.input { height: 34px; }
.textarea { resize: vertical; min-height: 72px; line-height: 1.65; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--pine);
  background: #fbfcfa;
  box-shadow: inset 0 0 0 1px var(--pine);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.select {
  height: 34px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 10px) 15px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

/* switch */
.switch {
  width: 34px; height: 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  position: relative;
  border-radius: 1px;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--muted);
  transition: transform var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.switch.is-on { background: var(--pine-100); border-color: var(--pine); }
.switch.is-on::after { transform: translateX(16px); background: var(--pine); }

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  background: var(--panel);
  height: 32px;
}
.stepper button {
  width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.stepper button:hover { background: var(--panel-3); color: var(--ink); }
.stepper__val {
  min-width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- progress ---------------- */

.progress {
  height: 2px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.progress > i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--pine);
  transition: width var(--dur-3) var(--ease);
}

/* ---------------- queue spine ---------------- */

.spine { display: flex; flex-wrap: wrap; gap: 3px; }
.spine__slot {
  width: 15px;
  height: 20px;
  border: 1px solid var(--line);
  background: transparent;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.spine__slot.is-filled { background: var(--pine); border-color: var(--pine); }
.spine__slot.is-session { background: var(--sage); border-color: var(--sage); }
.spine__slot.is-over { border-style: dashed; }

/* ---------------- toast ---------------- */

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 48px));
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  width: 100%;
  background: var(--ink);
  color: #eef1ec;
  padding: 11px 14px;
  border-left: 2px solid var(--sage);
  box-shadow: var(--shadow-pop);
  animation: toastin 240ms var(--ease);
  pointer-events: auto;
}
.toast.is-out { animation: toastout 200ms var(--ease) forwards; }
.toast__msg { font-size: 12.5px; line-height: 1.5; }
.toast__act {
  margin-left: auto;
  font-size: 11.5px;
  color: #cfe0d3;
  border-bottom: 1px solid rgba(207, 224, 211, .4);
  white-space: nowrap;
  align-self: center;
}
.toast__act:hover { color: #fff; border-color: #fff; }
.toast--warn { border-left-color: var(--st-b); }
.toast--error { border-left-color: var(--brick); }

@keyframes toastin {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastout {
  to { opacity: 0; transform: translateY(4px); }
}

/* ---------------- modal ---------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(20, 30, 25, .32);
  backdrop-filter: blur(2.5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  animation: fadein 160ms var(--ease);
}
.scrim.is-closing { animation: fadeout 140ms var(--ease) forwards; }

.modal {
  width: 560px;
  max-width: 100%;
  max-height: min(86vh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  animation: risein 220ms var(--ease);
}
.scrim.is-closing .modal { animation: riseout 140ms var(--ease) forwards; }

.modal__hd {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.modal__title { font-size: 16px; font-weight: 500; letter-spacing: -.005em; }
.modal__sub { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.modal__close { margin-left: auto; margin-top: -4px; margin-right: -6px; }
.modal__bd { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal__ft {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.modal__ft .spacer { flex: 1; }
.modal--wide { width: 680px; }
.modal--batch { width: min(1100px, 100%); }
.modal--slim { width: 460px; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes risein {
  from { opacity: 0; transform: translateY(10px) scale(.994); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes riseout {
  to { opacity: 0; transform: translateY(6px) scale(.996); }
}

/* option rows used in exit dialog */
.optrow {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.optrow:hover { border-color: var(--line-strong); background: var(--panel-2); }
.optrow:disabled { opacity: .48; cursor: not-allowed; background: var(--panel); }
.optrow:disabled:hover { border-color: var(--line); background: var(--panel); }
.optrow__n {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--faint);
  font-style: italic;
}
.optrow__t { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.optrow__d { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.optrow--danger .optrow__t { color: var(--brick); }
.optrow--danger:hover { border-color: var(--brick-line); background: var(--brick-bg); }

/* ---------------- empty state ---------------- */

.empty {
  border: 1px dashed var(--line-strong);
  padding: 40px 24px;
  text-align: center;
  background: transparent;
}
.empty__t { font-size: 13.5px; font-weight: 500; }
.empty__d { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.empty__act { margin-top: 16px; }

/* ---------------- icon base (sized by context) ---------------- */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: inline-block;
  vertical-align: -3px;
}

/* ============================================================
   V2 · colour hierarchy refinement
   ivory → panel → pine (primary) → sage (secondary) → slate (B)
   ============================================================ */

.btn { background: var(--panel); border-color: var(--line); color: var(--ink-soft); }
.btn:hover { background: var(--panel-2); border-color: var(--line-strong); color: var(--ink); }
.btn:active { background: var(--panel-3); }

.btn--primary { background: var(--pine); border-color: var(--pine); color: #f4f2e9; }
.btn--primary:hover { background: var(--pine-700); border-color: var(--pine-700); color: #fffdf6; }

/* secondary emphasis: mist green, for in-page actions */
.btn--soft {
  background: var(--sage-100);
  border-color: var(--sage-200);
  color: var(--pine);
}
.btn--soft:hover { background: var(--sage-200); border-color: var(--sage); color: var(--pine-700); }
.btn--soft:active { background: var(--sage-soft); }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn--ghost:hover { background: var(--panel); border-color: var(--line-strong); color: var(--ink); }

.btn--quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn--quiet:hover { background: var(--panel-2); color: var(--ink); }

.btn--mini { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--mini:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line-strong); }
.btn--mini.is-on { background: var(--sage-100); border-color: var(--sage-200); color: var(--pine); }

.btn--danger { color: var(--brick); border-color: var(--line); background: transparent; }
.btn--danger:hover { background: var(--brick-bg); border-color: var(--brick-line); color: var(--brick); }

/* filters: selected = mist green, not ink */
.chip.is-on {
  background: var(--sage-100);
  border-color: var(--sage-200);
  color: var(--pine);
  font-weight: 500;
}
.chip.is-on:hover { background: var(--sage-200); border-color: var(--sage); color: var(--pine-700); }
.chip:hover { background: var(--panel); border-color: var(--line-strong); color: var(--ink); }

.seg__btn.is-on { background: var(--sage-100); color: var(--pine); font-weight: 500; }
.seg__btn.is-on:hover { background: var(--sage-200); color: var(--pine-700); }

.tag {
  background: var(--panel-2);
  border-color: var(--line-2);
  color: var(--muted);
}
.tag--sand { background: var(--sand-100); border-color: var(--sand); color: #6f6552; }
.tag--soft { background: var(--sage-100); border-color: var(--sage-200); color: var(--pine); }
.tag--watch { background: var(--panel-warm); border-color: var(--sand); color: #6f6552; }

/* icon button hover warms up */
.icon-btn { color: var(--muted); }
.icon-btn:hover { background: var(--panel-3); color: var(--pine); }

/* links */
.link:hover { color: var(--pine); border-color: var(--pine); }
.link-quiet:hover { color: var(--ink); border-color: var(--line-strong); }

/* inputs */
.input, .textarea, .select { background: var(--panel); border-color: var(--line); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--pine);
  background: #fffdf7;
  box-shadow: inset 0 0 0 1px var(--pine);
}
::selection { background: var(--sage-200); color: var(--pine-700); }
:focus-visible { outline: 1px solid var(--pine); outline-offset: 2px; }

/* progress */
.progress { background: var(--line-2); }
.progress > i { background: var(--pine); }

/* stamp / state letters stay state-coloured */
.stamp { background: transparent; }
.stamp--a { background: var(--st-a-bg); border-color: var(--st-a-line); color: var(--st-a); }
.stamp--u { background: var(--panel-warm); border-color: var(--line-strong); color: var(--faint); }
.stamp--b { background: var(--st-b-bg); border-color: var(--st-b-line); color: var(--st-b); }
.stamp--c { background: var(--st-c-bg); border-color: var(--st-c-line); color: var(--st-c); }

/* nav numbers */
.nav__num {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .05em;
  color: var(--faint);
  width: 16px;
  flex: none;
}
.nav__item.is-active .nav__num { color: var(--sage); }

/* secondary navigation inside a section */
.subnav {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 3px;
  width: fit-content;
}
.subnav__btn {
  height: 28px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.subnav__btn:hover { background: var(--panel-2); color: var(--ink); }
.subnav__btn.is-on { background: var(--sage-100); color: var(--pine); font-weight: 500; }
.subnav__n { font-family: var(--font-mono); font-size: 9.5px; opacity: .7; }

/* breadcrumb + back */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  transition: color var(--dur-2) var(--ease), gap var(--dur-2) var(--ease);
}
.backlink:hover { color: var(--pine); gap: 10px; }
.backlink .icon { width: 13px; height: 13px; }

.crumb-trail { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--faint); }
.crumb-trail a:hover { color: var(--ink); }
.crumb-trail .sep { width: 10px; height: 1px; background: var(--line-strong); }

/* judge buttons (A / B / C self-assessment) */
.judge { display: flex; gap: 8px; flex-wrap: wrap; }
.judge__btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  transition: all var(--dur-2) var(--ease);
}
.judge__btn:hover { border-color: var(--line-strong); background: var(--panel-2); transform: translateY(-1px); }
.judge__btn .stamp { width: 20px; height: 20px; font-size: 13px; }
.judge__t { font-size: 12.5px; }
.judge__d { font-family: var(--font-mono); font-size: 9.5px; color: var(--faint); letter-spacing: .04em; }
.judge__btn.is-on[data-v="A"] { background: var(--st-a-bg); border-color: var(--st-a-line); }
.judge__btn.is-on[data-v="B"] { background: var(--st-b-bg); border-color: var(--st-b-line); }
.judge__btn.is-on[data-v="C"] { background: var(--st-c-bg); border-color: var(--st-c-line); }

/* small status dot */
.dotline { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.dotline::before { content: ""; width: 5px; height: 5px; background: var(--sage); border-radius: 50%; }
.dotline--warn::before { background: var(--sand); }
.dotline--idle::before { background: var(--line-strong); }

/* Note detail: keep the exported visual language while restoring its controls. */
.lib.is-collapsed { grid-template-columns: minmax(0, 1fr); }
.lib.is-collapsed .lib__side { display: none; }
.lib.is-collapsed .lib__main { padding-left: 0; }

.lib__collapse {
  display: block;
  margin: -8px 0 10px auto;
  padding: 4px 0;
  color: var(--muted);
  font-size: 11px;
  border-bottom: 1px solid transparent;
}
.lib__collapse:hover { color: var(--pine); border-bottom-color: var(--pine); }
.lib__collapse:focus-visible,
.lib__type-tab:focus-visible,
.note-state-tabs .chip:focus-visible { outline: 2px solid var(--pine); outline-offset: 3px; }
.lib .detail-head > :first-child { flex: 1 1 0; min-width: 0; }
.lib .detail-title { overflow-wrap: anywhere; }
.lib .detail-actions {
  flex: 0 0 auto;
  width: auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  white-space: nowrap;
}
.lib--detail .detail-actions { flex: 0 1 auto; min-width: 0; max-width: 100%; flex-wrap: wrap; white-space: normal; }
.lib .filters { border-bottom: 0; padding-bottom: 0; }
.note-state-tabs { gap: 20px; border-bottom: 1px solid var(--line); }
.note-state-tabs .chip {
  position: relative;
  height: 30px;
  padding: 0 0 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
}
.note-state-tabs .chip:hover,
.note-state-tabs .chip.is-on,
.note-state-tabs .chip.is-on:hover { border: 0; background: transparent; color: var(--ink); }
.note-state-tabs .chip.is-on::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--pine);
}
.lib__list-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.lib__toolrow { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.lib__toolrow .filters { flex: 1 1 0; min-width: 0; flex-direction: row; padding: 8px 0; }
.lib__toolrow .note-state-tabs { border-bottom: 0; }
.lib__toolrow .lib__list-tools { margin-left: auto; border-bottom: 0; }
.lib--detail .lib__toolrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.lib--detail .lib__toolrow .filters,
.lib--detail .lib__toolrow .lib__list-tools { min-width: 0; width: 100%; }
.lib--detail .lib__toolrow .lib__list-tools { flex-wrap: wrap; justify-content: flex-end; }
.lib--detail .lib__type-tabs { min-width: 0; max-width: 100%; flex-wrap: wrap; white-space: normal; }

.display-name-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.display-name-form .input { width: min(180px, 100%); }
.display-name-form [data-role="display-name-error"] { flex-basis: 100%; color: var(--brick); }


.lib__list-tools .searchbox { width: 196px; }
.lib__list-tools .searchbox input { min-width: 0; width: 100%; border: 0; background: transparent; outline: none; font-size: 12px; color: var(--ink); }
.lib__type-tabs { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.lib__type-tab { border: 0; padding: 3px 0; color: var(--muted); font-size: 12px; }
.lib__type-tab:hover,
.lib__type-tab.is-on { color: var(--pine); }
.lib__type-tab.is-on { border-bottom: 2px solid var(--pine); }
.lib__type-tab .num { font-size: 9.5px; opacity: .7; }
@media (max-width: 1500px) {
  .lib__toolrow { gap: 0; }
  .lib__toolrow .filters { flex: 1 0 100%; }
  .lib__toolrow .note-state-tabs { flex-wrap: nowrap; overflow-x: auto; }
}
@media (max-width: 760px) {
  .lib .detail-head { flex-direction: column; align-items: stretch; }
  .lib .detail-actions { width: 100%; margin-left: 0; justify-content: flex-end; }
  .lib__list-tools { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .lib .detail-actions { gap: 5px; }
  .lib .detail-actions .btn { flex: 1 1 0; min-width: 0; padding-inline: 5px; }
  .lib__list-tools .searchbox { width: 100%; }
  .lib__type-tabs { margin-left: auto; }
  .lib__list-tools .filters__count { display: none; }
  .note-state-tabs { gap: 14px; overflow-x: auto; flex-wrap: nowrap; }
  .note-state-tabs .chip { flex: none; }
}
/* AI preferences and preview retain the existing compact field language. */
.ai-pref-form { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; align-items:end; margin-top:16px; }
.ai-pref-form > button { grid-column:1 / -1; justify-self:start; }
.ai-pref-form--once { margin-top:0; }
.ai-content-form { display:grid; gap:14px; }
.ai-content-original { padding:9px 12px; background:var(--paper-deep,#ecebe6); overflow-wrap:anywhere; }
.ai-content-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 14px; }
.ai-content-fields .field:has(textarea) { grid-column:1 / -1; }
.ai-content-preview { display:grid; gap:6px; padding:12px 14px; background:var(--paper-deep,#ecebe6); overflow-wrap:anywhere; }
.ai-example-fields { grid-column:1 / -1; display:grid; gap:10px; }
.ai-example-pair { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.ai-apply-row { display:flex; flex-wrap:wrap; gap:16px; padding:8px 0; }
.ai-apply-row label { display:inline-flex; align-items:center; gap:6px; }
.ai-dictionary { display:grid; gap:15px; }
.ai-dictionary__top { display:flex; justify-content:space-between; align-items:baseline; gap:14px; flex-wrap:wrap; }
.ai-dictionary__original { font-size:20px; line-height:1.5; overflow-wrap:anywhere; }
.ai-dictionary__context { color:var(--muted,#777); font-size:11px; }
.ai-dictionary__phonetic { margin-left:12px; color:var(--muted,#777); font-size:13px; }
.ai-dictionary__group { background:var(--paper-deep,#ecebe6); padding:14px 16px; }
.ai-dictionary__pos { font-size:12px; color:var(--muted,#777); margin-bottom:10px; }
.ai-dictionary__sense { display:flex; gap:10px; align-items:flex-start; }
.ai-dictionary__select, .ai-dictionary__icon { border:0; background:transparent; color:inherit; cursor:pointer; padding:3px; }
.ai-dictionary__select { min-width:25px; font-size:18px; }
.ai-dictionary__icon { display:inline-flex; flex:none; opacity:.6; }
.ai-dictionary__icon:disabled { opacity:.28; cursor:not-allowed; }
.ai-dictionary__select:focus-visible, .ai-dictionary__icon:focus-visible { outline:2px solid var(--green,#54715f); outline-offset:2px; }
.ai-dictionary__copy { min-width:0; flex:1; display:grid; gap:12px; }
.ai-dictionary__line { display:flex; gap:8px; align-items:flex-start; overflow-wrap:anywhere; }
.ai-dictionary__line > span, .ai-dictionary__line > input, .ai-dictionary__line > textarea { min-width:0; flex:1; }
.ai-dictionary__example { display:grid; gap:4px; color:var(--muted,#777); font-size:13px; }
.ai-dictionary__overwrite { font-size:12px; }
.import-progress { position:fixed; right:20px; bottom:20px; z-index:110; width:min(360px,calc(100vw - 40px)); max-height:min(55vh,430px); overflow:auto; padding:14px 16px; background:var(--paper,#f6f4ee); color:var(--ink,#222); border:1px solid var(--rule,#d9d7cf); box-shadow:0 8px 22px rgba(0,0,0,.1); font-size:12px; }
.import-progress__head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.import-progress__failure { padding:7px 0; border-top:1px solid var(--rule,#d9d7cf); overflow-wrap:anywhere; }
.import-progress__failure button { border:0; background:transparent; color:inherit; text-decoration:underline; cursor:pointer; }
.mrow__ctx--translation, .mrow__context-note { opacity:.62; font-size:.85em; }
.lib__manage { display:flex; justify-content:flex-end; gap:18px; padding:6px 0; }
.display-preset-list, .display-field-list { display:flex; flex-wrap:wrap; gap:12px 20px; align-items:center; }
.display-field-list { margin-top:18px; padding:16px 0; border-top:1px solid var(--line); }
.display-field-list label { display:inline-flex; gap:6px; align-items:center; font-size:12px; }
.batch-manage__tools { display:flex; align-items:center; flex-wrap:wrap; gap:10px 20px; padding-bottom:12px; }
.batch-manage__tools label { display:inline-flex; align-items:center; gap:6px; }
.batch-manage__hide { margin-left:auto; }
.import-parse-options { display:flex; flex-wrap:wrap; align-items:center; gap:10px 24px; margin:0 0 12px; color:var(--muted); font-size:12px; }
.import-parse-options label { display:inline-flex; align-items:center; gap:8px; }
.import-parse-options .select { min-width:108px; }
.batch-manage__actions { display:flex; flex-wrap:wrap; gap:8px; }
.batch-manage__list { max-height:50vh; overflow:auto; border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.batch-manage__row { display:flex; align-items:center; gap:12px; min-height:40px; padding:6px 4px; border-bottom:1px solid var(--line-2); }
.batch-manage__row span { flex:1; min-width:0; overflow-wrap:anywhere; }
.batch-manage__row small { color:var(--muted); }
.batch-manage__job { padding:12px 14px; background:var(--paper-deep,#ecebe6); display:grid; gap:6px; font-size:12px; }
.batch-manage__confirm { display:flex; align-items:center; flex-wrap:wrap; gap:10px; padding:12px; background:var(--paper-deep,#ecebe6); }
.practice-modes { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.practice-mode { display:flex; flex-direction:column; align-items:flex-start; min-width:0; min-height:86px; white-space:normal; }
.practice-mode .optrow__t, .practice-mode .optrow__d { display:block; width:100%; writing-mode:horizontal-tb; overflow-wrap:break-word; }
.material-state-choices { display:inline-flex; align-items:center; gap:3px; flex-wrap:nowrap; }
.material-state-choices button { width:27px; height:29px; border:1px solid transparent; background:transparent; color:var(--muted); font-family:var(--font-mono); cursor:pointer; }
.material-state-choices button:hover:not(:disabled), .material-state-choices button.is-on { border-color:var(--line-strong); color:var(--ink); background:var(--panel-2); }
.material-state-choices button.is-on.is-a { color:var(--st-a); background:var(--st-a-bg); }
.material-state-choices button.is-on.is-b { color:var(--st-b); background:var(--st-b-bg); }
.material-state-choices button.is-on.is-c { color:var(--st-c); background:var(--st-c-bg); }
.material-state-choices button:disabled { cursor:default; opacity:.55; }
.material-state-choices button:focus-visible { outline:2px solid var(--pine); outline-offset:2px; }
.mrow__select { grid-column:1; justify-self:center; width:16px; height:16px; accent-color:var(--pine); }
.state-bulk { display:flex; align-items:center; gap:14px; flex-wrap:wrap; padding:12px 16px; border-bottom:1px solid var(--line); color:var(--ink-soft); font-size:12px; }
@media (max-width:700px) { .practice-modes { grid-template-columns:1fr; } .batch-manage__hide { margin-left:0; } }
.ai-dictionary__focus { color:var(--pine); font-size:10px; letter-spacing:.08em; }
.content-editor { display:grid; gap:12px; }
.content-editor__sense { padding:13px 0; border-bottom:1px solid var(--line); }
.content-editor__head { display:flex; align-items:baseline; gap:7px; flex-wrap:wrap; }
.content-editor__head > .link-quiet { margin-left:auto; }
.content-editor__example { display:grid; gap:5px; padding-top:9px; color:var(--ink-soft); }
.content-editor__field { display:inline-flex; align-items:baseline; gap:4px; min-width:0; max-width:100%; overflow-wrap:anywhere; }
.content-editor__field > span { min-width:0; }
.content-editor__field .input { min-width:90px; }
.content-editor__field .textarea { min-width:min(520px,65vw); min-height:60px; }
.content-editor__example .content-editor__field { display:flex; }
.content-editor__sense .ai-dictionary__icon { padding:1px; }
.mrow--note { grid-template-columns: 22px minmax(0,1fr) minmax(0,120px) max-content; align-items:center; }
.mrow--note.is-selectable { grid-template-columns:22px 22px minmax(0,1fr) minmax(0,120px) max-content; }
.mrow--note.is-selectable { cursor:pointer; }
.mrow--note.is-selected { background:var(--pine-100); box-shadow:inset 2px 0 var(--pine); }
.mrow--note.is-selectable:focus-visible { outline:2px solid var(--pine); outline-offset:-2px; }
.mrow--note.is-selectable .material-state-control { grid-column:2; }
.mrow--note.is-selectable .mrow__main { grid-column:3; }
.mrow--note.is-selectable .mrow__meta { grid-column:4; }
.mrow--note.is-selectable .mrow__act { grid-column:5; }
.note-bulk { display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:12px 0; border-bottom:1px solid var(--line); font-size:12px; }
.note-bulk__actions { display:flex; gap:4px; flex-wrap:wrap; }
.note-bulk__actions button { padding:6px 8px; border:1px solid var(--line); background:transparent; color:var(--ink); cursor:pointer; }
.note-bulk__actions button:hover:not(:disabled) { border-color:var(--pine); }
.note-bulk__actions button:disabled { opacity:.4; cursor:not-allowed; }
.note-bulk [role="status"] { flex-basis:100%; color:var(--muted); overflow-wrap:anywhere; }
.mrow--note .material-state-control { grid-column:1; justify-self:start; }
.mrow--note .material-state-trigger.stamp { width:22px; height:22px; min-height:22px; padding:0; font-size:14px; }
.mrow--note .material-state-menu { left:0; right:auto; }
.mrow--note .mrow__main { grid-column:2; display:grid; grid-template-columns:minmax(0,1fr); gap:4px; min-width:0; width:100%; }
.mrow--note .mrow__line, .mrow--note .mrow__example-line { display:flex; align-items:baseline; flex-wrap:nowrap; gap:9px; min-width:0; overflow:hidden; }
.mrow--note .mrow__w { flex:0 1 auto; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:18px; }
.mrow--note.mrow--word .mrow__w { flex:none; max-width:none; overflow:visible; text-overflow:clip; }
.mrow--note .mrow__ipa, .mrow--note .mrow__pos { flex:none; }
.mrow--note .mrow__meaning { flex:0 1 auto; min-width:0; max-width:none; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; border:0; padding:0; margin:0; }
.mrow--note .mrow__example-line { color:var(--muted); font-size:12px; }
.mrow--note .mrow__example-en, .mrow--note .mrow__example-zh { flex:0 1 auto; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.mrow--note .mrow__example-zh { color:var(--ink-soft); }
.mrow--note .mrow__expand { flex:none; border:0; padding:0 2px; background:transparent; color:var(--muted); font-size:10px; cursor:pointer; }
.mrow--note .mrow__expand:focus-visible { outline:2px solid var(--pine); outline-offset:2px; }
.mrow--note .mrow__meta { grid-column:3; max-width:120px; overflow:hidden; flex-wrap:nowrap; }
.mrow--note .mrow__act { grid-column:4; min-width:0; justify-self:end; }
.mrow--note .mrow__act .icon-btn { flex:none; width:30px; height:30px; border:1px solid transparent; }
.mrow--note .mrow__act .icon-btn:hover:not(:disabled), .mrow--note .mrow__act .icon-btn.is-on { background:var(--sage-100); border-color:var(--sage-200); color:var(--pine); }
.mrow--note .mrow__act .icon-btn:disabled { opacity:.4; cursor:not-allowed; }
.mrow--note .mrow__act .icon-btn:focus-visible { outline:2px solid var(--pine); outline-offset:2px; }
.mrow--note .mrow__act [data-act="unlink"]:hover { background:var(--brick-bg); border-color:var(--brick-line); color:var(--brick); }
.detail-note > span.detail-note__tags { display:flex; flex-wrap:wrap; gap:6px; overflow:visible; white-space:normal; }
.detail-note .note-tag { height:20px; padding:0 7px; font-size:11px; }
.note-card--selectable { cursor:pointer; user-select:none; }
.note-card--selectable:focus-visible { outline:2px solid var(--pine); outline-offset:3px; }
.note-card--selectable.is-selected { border-color:var(--pine); background:var(--sage-100); }
.note-card--selectable.is-selected::before { transform:scaleY(1); }
.note-card__choice { width:18px; height:18px; flex:none; display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--line-strong); color:var(--panel); }
.note-card__choice .icon { width:13px; height:13px; }
.note-card--selectable.is-selected .note-card__choice { border-color:var(--pine); background:var(--pine); }
.overview-bulk { display:flex; align-items:center; flex-wrap:wrap; gap:10px 14px; margin-top:18px; padding:11px 14px; border:1px solid var(--line); background:var(--panel); font-size:12px; }
.overview-bulk .btn .icon { width:14px; height:14px; margin-right:5px; }
.overview-bulk__notice { flex-basis:100%; color:var(--ink-soft); }
.mrow--note.is-expanded .mrow__line, .mrow--note.is-expanded .mrow__example-line { flex-wrap:wrap; overflow:visible; }
.mrow--note.is-expanded .mrow__w, .mrow--note.is-expanded .mrow__meaning, .mrow--note.is-expanded .mrow__example-en, .mrow--note.is-expanded .mrow__example-zh { white-space:normal; overflow:visible; overflow-wrap:anywhere; }
.is-narrow .mrow--note { grid-template-columns:22px minmax(0,1fr); align-items:start; }
.is-narrow .mrow--note.is-selectable { grid-template-columns:22px 22px minmax(0,1fr); }
.is-narrow .mrow--note.is-selectable .mrow__main, .is-narrow .mrow--note.is-selectable .mrow__meta, .is-narrow .mrow--note.is-selectable .mrow__act { grid-column:3; }
.is-narrow .mrow--note .mrow__line, .is-narrow .mrow--note .mrow__example-line { flex-wrap:wrap; overflow:visible; }
.is-narrow .mrow--note .mrow__w, .is-narrow .mrow--note .mrow__meaning, .is-narrow .mrow--note .mrow__example-en, .is-narrow .mrow--note .mrow__example-zh { white-space:normal; overflow:visible; overflow-wrap:anywhere; }
.is-narrow .mrow--note.mrow--word .mrow__w { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.is-narrow .mrow--note .mrow__meta { grid-column:2; max-width:none; }
.is-narrow .mrow--note .mrow__act { grid-column:2; flex-wrap:wrap; }
@media (max-width:700px) {
  .ai-pref-form, .ai-content-fields { grid-template-columns:1fr; }
  .ai-content-fields .field:has(textarea) { grid-column:auto; }
  .ai-example-fields { grid-column:auto; }
  .ai-example-pair { grid-template-columns:1fr; }
}
