/* =========================================================================
   강해지는 프롬프트! (Tsuyokunaru)
   Design system - tinted glassmorphism.

   Built from the emerald glass card recipe: a low-alpha tinted fill,
   blur(20px) saturate(160%), a mint hairline border, a deep coloured drop
   shadow and one soft inset white glow. No displacement filter.

   Pill controls and the inset-track / raised-thumb treatment on toggles
   come from the neumorphic reference, rendered in the glass idiom.

   Shape rule (locked):
     panels / sheets  -> --r-lg (18px)
     cards / rows     -> --r-md (12px)
     inputs           -> --r-sm (10px)
     buttons, toggles -> --r-pill (9999px)

   Accent rule (locked): one family only, the emerald / mint ramp.
   The crimson logo is the single warm element, and that is deliberate.
   ========================================================================= */

/* ---------- 1. Tokens ---------------------------------------------------- */

:root {
  /* Emerald ramp, seeded from the border colour of the reference card */
  --em-950: #022c22;
  --em-900: #064e3b;
  --em-800: #065f46;
  --em-700: #047857;
  --em-600: #059669;
  --em-500: #10b981;
  --em-400: #34d399;
  --em-300: #6ee7b7;
  --em-200: #a7f3d0;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-pill: 9999px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-1: 0.16s;
  --dur-2: 0.28s;
  --dur-3: 0.45s;

  --z-base: 1;
  --z-chrome: 20;
  --z-sheet: 60;
  --z-popover: 80;
  --z-modal: 100;
  --z-toast: 120;

  --shell-max: 1180px;
  --read-max: 74ch;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #04110d;

  --ink: #eaf6f1;
  --ink-2: rgba(234, 246, 241, 0.75);
  /* 0.65 keeps 12px muted text at WCAG AA even over the brightest
     part of the aurora showing through the glass. Do not lower it. */
  --ink-3: rgba(234, 246, 241, 0.65);
  --ink-4: rgba(234, 246, 241, 0.2);

  --accent: var(--em-300);
  --accent-strong: var(--em-200);
  --accent-ink: #022c22;
  --accent-wash: rgba(110, 231, 183, 0.12);

  /* The reference recipe, verbatim */
  --glass-base: rgba(6, 78, 59, 0.18);
  --glass-raise: rgba(6, 78, 59, 0.34);
  --glass-border: rgba(110, 231, 183, 0.2);
  --glass-border-strong: rgba(110, 231, 183, 0.42);
  --glass-specular: inset 0 0 4px 2px rgba(255, 255, 255, 0.05);
  --glass-drop: 0 10px 30px 0 rgba(2, 44, 34, 0.25);
  --glass-drop-lift: 0 18px 44px 0 rgba(2, 44, 34, 0.42);
  --glass-blur: blur(20px) saturate(160%);

  /* Reading surface stays opaque. Long-form text never sits on live blur. */
  --paper: #081914;
  --paper-2: #0c2119;
  --paper-line: rgba(110, 231, 183, 0.12);

  --field: rgba(2, 26, 20, 0.42);
  --field-line: rgba(110, 231, 183, 0.18);
  --inset: inset 0 2px 6px rgba(2, 20, 15, 0.5);

  --mark-bg: rgba(255, 196, 84, 0.2);
  --mark-line: #e8a33c;
  --mark-ink: #ffd98f;
  --mark-bg-hover: rgba(255, 196, 84, 0.32);

  --danger: #fb7185;
  --danger-wash: rgba(251, 113, 133, 0.14);
  --ok: var(--em-400);
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #e8f6f0;

  --ink: #072019;
  --ink-2: rgba(7, 32, 25, 0.75);
  /* Same AA floor as dark mode. See the note there. */
  --ink-3: rgba(7, 32, 25, 0.65);
  --ink-4: rgba(7, 32, 25, 0.16);

  --accent: var(--em-700);
  --accent-strong: var(--em-800);
  --accent-ink: #ffffff;
  --accent-wash: rgba(4, 120, 87, 0.1);

  --glass-base: rgba(255, 255, 255, 0.44);
  --glass-raise: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-border-strong: rgba(4, 120, 87, 0.34);
  --glass-specular: inset 0 0 4px 2px rgba(255, 255, 255, 0.5);
  --glass-drop: 0 10px 30px 0 rgba(2, 44, 34, 0.12);
  --glass-drop-lift: 0 18px 44px 0 rgba(2, 44, 34, 0.18);
  --glass-blur: blur(20px) saturate(160%);

  --paper: #ffffff;
  --paper-2: #f2fbf7;
  --paper-line: rgba(7, 32, 25, 0.1);

  --field: rgba(255, 255, 255, 0.7);
  --field-line: rgba(7, 32, 25, 0.14);
  --inset: inset 0 2px 6px rgba(2, 44, 34, 0.09);

  --mark-bg: #ffe9a8;
  --mark-line: #d59a1a;
  --mark-ink: #4a3405;
  --mark-bg-hover: #ffdf85;

  --danger: #be123c;
  --danger-wash: rgba(190, 18, 60, 0.09);
  --ok: var(--em-700);
}

/* ---------- 2. Reset & base --------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* Both set by theme.jsx. TKBody splits Hangul+Latin from kana+kanji. */
  font-family: var(
    --font-body,
    "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
      system-ui, "Segoe UI", sans-serif
  );
  font-size: calc(15px * var(--font-scale, 1));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

::selection {
  background: var(--accent-wash);
  color: var(--accent);
}

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

.mono {
  font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--ink-4);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
  background-clip: content-box;
}

/* ---------- 3. Backdrop ---------------------------------------------------
   Three modes, all driven by CSS variables that the settings panel writes:
   the drifting aurora, a flat colour, or a wallpaper.

   The wallpaper never stretches. `cover` crops, `contain` letterboxes, and
   the letterbox is filled with a blurred blown-up copy of the same image so
   a portrait picture on a wide screen still looks deliberate.
   ----------------------------------------------------------------------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bd-color, var(--bg));
}

/* Blurring an element bleeds transparent edges inward, so the layer is
   inflated past the viewport by twice the blur radius. */
.backdrop__layer {
  position: absolute;
  inset: calc(-2 * var(--bd-blur, 0px) - 8px);
  background-position: center center;
  background-repeat: no-repeat;
  filter: blur(var(--bd-blur, 0px));
  transform: translateZ(0);
}

.backdrop__fill {
  background-image: var(--bd-image, none);
  background-size: cover;
  filter: blur(28px) saturate(140%);
  opacity: 0.85;
}

.backdrop__photo {
  background-image: var(--bd-image, none);
  background-size: var(--bd-size, cover);
  background-repeat: var(--bd-repeat, no-repeat);
}

.backdrop__dim {
  position: absolute;
  inset: 0;
  background: var(--bd-dim-color, transparent);
}

.aurora[data-mode="color"] .backdrop__layer,
.aurora[data-mode="color"] .aurora__blob,
.aurora[data-mode="color"] .aurora__grain,
.aurora[data-mode="image"] .aurora__blob {
  display: none;
}

.aurora[data-mode="image"] .aurora__grain {
  opacity: 0.02;
}

.aurora[data-mode="aurora"] .backdrop__layer,
.aurora[data-mode="aurora"] .backdrop__dim {
  display: none;
}

.aurora__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}

html[data-theme="dark"] .aurora__blob--a {
  background: radial-gradient(circle, var(--aurora-a, #065f46), transparent 66%);
  opacity: 0.8;
}
html[data-theme="dark"] .aurora__blob--b {
  background: radial-gradient(circle, var(--aurora-b, #0f766e), transparent 66%);
  opacity: 0.6;
}
html[data-theme="dark"] .aurora__blob--c {
  background: radial-gradient(circle, var(--aurora-c, #155e75), transparent 66%);
  opacity: 0.45;
}

html[data-theme="light"] .aurora__blob--a {
  background: radial-gradient(circle, var(--aurora-a, #a7f3d0), transparent 66%);
  opacity: 0.95;
}
html[data-theme="light"] .aurora__blob--b {
  background: radial-gradient(circle, var(--aurora-b, #99f6e4), transparent 66%);
  opacity: 0.85;
}
html[data-theme="light"] .aurora__blob--c {
  background: radial-gradient(circle, var(--aurora-c, #bfdbfe), transparent 66%);
  opacity: 0.7;
}

.aurora__blob--a {
  width: 62vw;
  height: 62vw;
  min-width: 520px;
  min-height: 520px;
  top: -22vw;
  left: -14vw;
  animation: drift-a 34s var(--ease-in-out) infinite alternate;
}
.aurora__blob--b {
  width: 54vw;
  height: 54vw;
  min-width: 460px;
  min-height: 460px;
  bottom: -20vw;
  right: -12vw;
  animation: drift-b 42s var(--ease-in-out) infinite alternate;
}
.aurora__blob--c {
  width: 40vw;
  height: 40vw;
  min-width: 340px;
  min-height: 340px;
  top: 34%;
  right: 22%;
  animation: drift-c 50s var(--ease-in-out) infinite alternate;
}

@keyframes drift-a {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(9vw, 7vh, 0) scale(1.14);
  }
}
@keyframes drift-b {
  from {
    transform: translate3d(0, 0, 0) scale(1.08);
  }
  to {
    transform: translate3d(-11vw, -8vh, 0) scale(0.94);
  }
}
@keyframes drift-c {
  from {
    transform: translate3d(0, 0, 0) scale(0.92);
  }
  to {
    transform: translate3d(-7vw, 10vh, 0) scale(1.2);
  }
}

.aurora__grain {
  position: absolute;
  inset: -50%;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* ---------- 4. Glass surfaces ------------------------------------------- */

.glass {
  position: relative;
  isolation: isolate;
  background: var(--glass-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--glass-drop), var(--glass-specular);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.glass--panel {
  border-radius: var(--r-lg);
}

.glass--raised {
  background: var(--glass-raise);
}

.glass--flat {
  box-shadow: var(--glass-specular);
}

/* Accessibility fallback: users who ask for less transparency get solid fills. */
@media (prefers-reduced-transparency: reduce) {
  .glass {
    background: var(--paper);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ---------- 5. Controls -------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  white-space: nowrap;
  border-radius: var(--r-pill);
  padding: 0.68em 1.35em;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform var(--dur-1) var(--ease),
    background-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}

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

.btn i {
  font-size: 1.15em;
  line-height: 1;
}

.btn--primary {
  background: linear-gradient(170deg, var(--em-500), var(--em-700));
  color: #012019;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 8px 22px rgba(2, 44, 34, 0.34);
}
.btn--primary:hover {
  background: linear-gradient(170deg, var(--em-500), var(--em-700));
}

.btn--glass {
  background: var(--glass-base);
  border: 1px solid var(--glass-border);
  color: var(--ink);
  box-shadow: var(--glass-specular);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.btn--glass:hover {
  border-color: var(--glass-border-strong);
  background: var(--accent-wash);
  color: var(--accent);
}

.btn--quiet {
  color: var(--ink-2);
  background: transparent;
}
.btn--quiet:hover {
  color: var(--accent);
  background: var(--accent-wash);
}

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

.btn--sm {
  padding: 0.5em 1em;
  font-size: 13px;
}
.btn--lg {
  padding: 0.85em 1.7em;
  font-size: 15px;
}
.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  font-size: 17px;
  transition: background-color var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.iconbtn:hover {
  background: var(--accent-wash);
  color: var(--accent);
}
.iconbtn:active {
  transform: scale(0.92);
}
.iconbtn--sm {
  width: 30px;
  height: 30px;
  font-size: 15px;
}

/* Segmented control: inset track, raised active pill.
   Straight out of the neumorphic reference, in glass materials. */
.seg {
  display: flex;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-pill);
  background: var(--field);
  border: 1px solid var(--field-line);
  box-shadow: var(--inset);
}
.seg__item {
  flex: 1;
  padding: 0.45em 0.9em;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.seg__item:hover {
  color: var(--ink-2);
}
.seg__item[aria-pressed="true"] {
  color: var(--accent);
  background: var(--glass-raise);
  box-shadow: var(--glass-drop), var(--glass-specular);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}
.field__input,
.field__area {
  width: 100%;
  padding: 0.85em 1.05em;
  border-radius: var(--r-sm);
  background: var(--field);
  border: 1px solid var(--field-line);
  color: var(--ink);
  box-shadow: var(--inset);
  transition: border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}
.field__area {
  resize: none;
  line-height: 1.7;
}
.field__input::placeholder,
.field__area::placeholder {
  color: var(--ink-3);
}
.field__input:focus,
.field__area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset), 0 0 0 3px var(--accent-wash);
}
.field__help {
  font-size: 12px;
  color: var(--ink-3);
}
.field__error {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-wash);
  color: var(--accent);
  white-space: nowrap;
}
.chip--count {
  background: linear-gradient(170deg, var(--em-500), var(--em-700));
  color: #012019;
  padding: 3px 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.chip--muted {
  background: var(--field);
  color: var(--ink-3);
  box-shadow: var(--inset);
}
/* Holds the comment-count column open on rows that have no comments yet,
   so titles and timestamps stay on the same vertical rhythm down the list. */
.chip--ghost {
  background: none;
  padding: 3px 0;
  min-width: 26px;
}

/* ---------- 6. App shell ------------------------------------------------- */

.app {
  position: relative;
  z-index: var(--z-base);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* The bar lines up with the list underneath it rather than running edge to
   edge, so the page reads as one column. */
.topbar-rail {
  position: sticky;
  top: 0;
  z-index: var(--z-chrome);
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 12px 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: var(--r-lg);
}

.topbar--wide {
  max-width: none;
}
.topbar-rail--wide {
  max-width: none;
  padding: 12px 12px 0;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.topbar__logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(2, 44, 34, 0.45));
}
.topbar__title {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar__spacer {
  flex: 1;
  min-width: 0;
}
.topbar__tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Just the avatar. The name is a tooltip, not a column of chrome. */
.userchip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-ink);
  background: linear-gradient(150deg, var(--em-500), var(--em-800));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform var(--dur-1) var(--ease);
}
.userchip:hover {
  transform: scale(1.06);
}

/* ---------- 7. Auth ------------------------------------------------------ */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth__card {
  width: 100%;
  max-width: 420px;
  padding: 38px 34px 30px;
}

.auth__head {
  text-align: center;
  margin-bottom: 28px;
}
.auth__logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 14px;
  filter: drop-shadow(0 10px 26px rgba(2, 44, 34, 0.5));
}
.auth__title {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
}
.auth__sub {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-2);
}

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

.auth__switch {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--paper-line);
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
}
.auth__switch button {
  color: var(--accent);
  font-weight: 700;
  margin-left: 6px;
}
.auth__switch button:hover {
  text-decoration: underline;
}

/* ---------- 8. Library --------------------------------------------------- */

.library {
  flex: 1;
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 18px 24px 56px;
}

.library__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.library__heading {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.library__meta {
  margin-top: 5px;
  font-size: 14px;
  color: var(--ink-2);
}

.library__search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.library__search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 16px;
  pointer-events: none;
}
.library__search input {
  width: 100%;
  padding: 0.66em 1em 0.66em 2.5em;
  border-radius: var(--r-pill);
  background: var(--field);
  border: 1px solid var(--field-line);
  color: var(--ink);
  box-shadow: var(--inset);
}
.library__search input::placeholder {
  color: var(--ink-3);
}
.library__search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset), 0 0 0 3px var(--accent-wash);
}

/* The single entry point: paste whatever is on the clipboard and go. */
.paste-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  margin-bottom: 22px;
  border-radius: var(--r-lg);
  text-align: left;
  color: var(--ink);
  border: 1px solid var(--glass-border-strong);
  transition: transform var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.paste-cta:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-drop-lift), var(--glass-specular);
}
.paste-cta:active {
  transform: translateY(0) scale(0.995);
}
.paste-cta__badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--r-pill);
  font-size: 23px;
  color: #012019;
  background: linear-gradient(160deg, var(--em-500), var(--em-800));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 6px 18px rgba(2, 44, 34, 0.35);
}
.paste-cta__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.paste-cta__title {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.paste-cta__sub {
  font-size: 13px;
  color: var(--ink-2);
}
.paste-cta__go {
  font-size: 19px;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform var(--dur-2) var(--ease);
}
.paste-cta:hover .paste-cta__go {
  transform: translateX(4px);
}

/* ---------- Statistics ---------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.stat {
  padding: 13px 15px;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat__label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.stat__label i {
  font-size: 13px;
}
.stat__value {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat__unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: 2px;
}
.stat__sub {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Seven days of activity. Tall enough that a quiet day and a busy day are
   actually distinguishable, with the day letter under each column. */
.sparkcard {
  gap: 10px;
}
.spark {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 108px;
  margin-top: 2px;
}
.spark__col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.spark__track {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  border-radius: 6px;
  background: var(--field);
  box-shadow: var(--inset);
  overflow: hidden;
}
.spark__bar {
  width: 100%;
  min-height: 3px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--em-400), var(--em-700));
  opacity: 0.55;
  transition: height var(--dur-3) var(--ease), opacity var(--dur-2) var(--ease);
}
.spark__col:hover .spark__bar {
  opacity: 0.85;
}
.spark__bar--today {
  opacity: 1;
  box-shadow: 0 0 12px -2px var(--accent);
}
.spark__day {
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  color: var(--ink-3);
  white-space: nowrap;
}
.spark__day--today {
  color: var(--accent);
}
.spark__peak {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Library toolbar ----------------------------------------------- */

.libbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.libbar .seg {
  flex-shrink: 0;
}

.catbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.catpill {
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3);
  background: var(--field);
  border: 1px solid var(--field-line);
  transition: color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.catpill:hover {
  color: var(--ink);
}
.catpill[aria-pressed="true"] {
  color: var(--accent-ink);
  background: linear-gradient(170deg, var(--em-500), var(--em-700));
  border-color: transparent;
}

.group {
  margin-bottom: 22px;
}
.group__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px 8px;
}
.group__title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 7px;
}
.group__title i {
  color: var(--accent);
  font-size: 15px;
}
.group__count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.group__line {
  flex: 1;
  height: 1px;
  background: var(--paper-line);
}
.group__actions {
  display: flex;
  gap: 2px;
}

/* Document list. Rows, not cards. */
.doclist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.docrow {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease);
}
.docrow:hover {
  transform: translateX(3px);
  border-color: var(--glass-border-strong);
  box-shadow: var(--glass-drop-lift), var(--glass-specular);
}

.docrow__badge {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  font-size: 17px;
  color: var(--accent);
  background: var(--accent-wash);
}

.docrow__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.docrow__title {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docrow__excerpt {
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docrow__time {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.docrow__actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.docrow:hover .docrow__actions,
.docrow:focus-within .docrow__actions {
  opacity: 1;
  transform: none;
}

/* ---------- 9. Empty / loading / error states ---------------------------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-3);
}
.state__icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: var(--r-pill);
  background: var(--field);
  border: 1px solid var(--field-line);
  box-shadow: var(--inset);
  font-size: 25px;
  color: var(--ink-3);
}
.state__title {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--ink-2);
  letter-spacing: -0.02em;
}
.state__body {
  font-size: 14px;
  line-height: 1.7;
  max-width: 42ch;
}

.skeleton {
  border-radius: var(--r-md);
  height: 64px;
  background: var(--field);
  border: 1px solid var(--field-line);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.09) 45%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

/* ---------- 10. Editor workspace ---------------------------------------- */

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  gap: 12px;
  /* The top padding is the breathing room between the title bar and the
     panes. Without it the two glass blocks touch and read as one. */
  padding: 14px 12px 12px;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
}

.pane--notes {
  width: 370px;
  flex-shrink: 0;
}
.pane--reader {
  flex: 1;
  min-width: 0;
}

.pane__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--paper-line);
  flex-shrink: 0;
}
.pane__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.015em;
}
.pane__title i {
  color: var(--accent);
  font-size: 17px;
}
.pane__hint {
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 500;
}
.pane__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pane__foot {
  flex-shrink: 0;
  padding: 11px 15px;
  border-top: 1px solid var(--paper-line);
}

.reader {
  background: var(--paper-override, var(--paper));
}

/* "배경 비치기": the wallpaper shows through the reading pane, with its own
   blur and its own scrim so body text keeps a solid contrast floor. */
html[data-reader="glass"] .reader {
  background: transparent;
  backdrop-filter: blur(var(--reader-blur, 18px)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--reader-blur, 18px)) saturate(140%);
}
html[data-reader="glass"] .reader::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--reader-dim, rgba(0, 0, 0, 0.4));
  pointer-events: none;
  z-index: 0;
}
html[data-reader="glass"] .reader > * {
  position: relative;
  z-index: 1;
}
.pane--reader {
  position: relative;
}
.reader__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 34px 30px 120px;
}
.reader__doc {
  max-width: var(--read-max);
  margin: 0 auto;
  position: relative;
  font-size: 17px;
}

.notes__scroll {
  padding: 18px 15px 80px;
}
.notes__track {
  position: relative;
  width: 100%;
}
.notes__track--static {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--paper-2);
  border: 1px solid var(--paper-line);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}
.note:hover {
  border-color: var(--accent);
  box-shadow: var(--glass-drop);
}
.note--orphan {
  opacity: 0.62;
  border-style: dashed;
  cursor: default;
}
.note__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.note__actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.note:hover .note__actions,
.note:focus-within .note__actions {
  opacity: 1;
}
.note__quote {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-3);
  padding: 8px 11px;
  border-radius: var(--r-sm);
  background: var(--field);
  border-left: 2px solid var(--accent);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.note__comment {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 11. Compose -------------------------------------------------- */

.compose {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 4px 24px 44px;
  display: flex;
  flex-direction: column;
}
.compose__card {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.compose__heading {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.035em;
}
.compose__sub {
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-2);
}
.compose__area {
  min-height: 44vh;
  font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 13.5px;
}
.compose__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- 12. Marks & prose ------------------------------------------- */

.prose {
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}
.prose h1 {
  font-size: 1.7em;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 1.2em 0 0.5em;
}
.prose h2 {
  font-size: 1.4em;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 1.2em 0 0.5em;
}
.prose h3 {
  font-size: 1.18em;
  font-weight: 700;
  margin: 1.1em 0 0.4em;
}
.prose p {
  margin-bottom: 1em;
}
.prose ul {
  list-style: disc;
  padding-left: 1.4em;
  margin-bottom: 1em;
}
.prose ol {
  list-style: decimal;
  padding-left: 1.5em;
  margin-bottom: 1em;
}
.prose li {
  margin-bottom: 0.35em;
}
.prose blockquote {
  border-left: 3px solid var(--accent);
  background: var(--field);
  color: var(--ink-2);
  padding: 0.7em 1.1em;
  margin: 0 0 1em;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.prose code {
  background: var(--field);
  border: 1px solid var(--field-line);
  padding: 0.14em 0.42em;
  border-radius: 6px;
  font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.88em;
  color: var(--accent);
}
.prose pre {
  background: var(--field);
  border: 1px solid var(--field-line);
  padding: 1em 1.2em;
  border-radius: var(--r-md);
  overflow-x: auto;
  margin-bottom: 1em;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
}
.prose hr {
  border: none;
  border-top: 1px solid var(--paper-line);
  margin: 1.8em 0;
}
.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
  font-size: 0.94em;
}
.prose th,
.prose td {
  padding: 0.55em 0.8em;
  border: 1px solid var(--paper-line);
  text-align: left;
}
.prose th {
  background: var(--field);
  font-weight: 700;
}

/* MathJax capture trick, carried over from v1. Do not restyle. */
.raw-math {
  font-size: 0;
  width: 0;
  height: 0;
  display: inline-block;
  overflow: hidden;
  color: transparent;
  user-select: text;
}
.math-render {
  user-select: none;
}
.math-wrapper {
  display: inline-block;
  padding: 0 2px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 0 1.5px transparent;
  transition: box-shadow var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease);
}
.math-wrapper:hover {
  box-shadow: 0 0 0 1.5px var(--accent);
  background: var(--accent-wash);
}

.highlight-mark {
  background: var(--mark-bg);
  border-bottom: 2px solid var(--mark-line);
  color: var(--mark-ink);
  border-radius: 4px;
  padding: 0.08em 0.1em;
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease);
}
.highlight-mark:hover {
  background: var(--mark-bg-hover);
}

.flash-mark {
  animation: flash-mark 1.4s var(--ease) 1;
}
@keyframes flash-mark {
  0% {
    box-shadow: 0 0 0 5px var(--accent-wash);
    background: var(--accent-wash);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
    background: var(--mark-bg);
  }
}

/* ---------- 13. Popover -------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(1, 16, 12, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in var(--dur-2) var(--ease);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.popover {
  position: fixed;
  z-index: var(--z-popover);
  width: 372px;
  max-width: calc(100vw - 32px);
  padding: 17px;
  transform: translateX(-50%);
  background: var(--glass-raise);
  animation: popover-in var(--dur-2) var(--ease);
}
.popover--above {
  transform: translate(-50%, -100%);
}
@keyframes popover-in {
  from {
    opacity: 0;
    scale: 0.96;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

.popover__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.popover__quote {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--field);
  border: 1px solid var(--field-line);
  border-left: 2px solid var(--accent);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  max-height: 5.4em;
  overflow: hidden;
  word-break: break-word;
}
.popover__area {
  height: 96px;
  margin-bottom: 14px;
}
.popover__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.popover__foot .btn--danger {
  margin-right: auto;
}

.tip {
  position: fixed;
  z-index: var(--z-popover);
  max-width: 300px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--glass-raise);
  transform: translate(-50%, -100%);
  pointer-events: none;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  animation: fade-in var(--dur-1) var(--ease);
}
.tip__hint {
  display: block;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
}

/* ---------- 14. Sheet ---------------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: var(--z-sheet);
  width: min(820px, 100vw);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  background: var(--glass-raise);
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease);
}
.sheet--open {
  transform: none;
}
.sheet__head {
  flex-shrink: 0;
  padding: 18px 22px;
  border-bottom: 1px solid var(--paper-line);
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.sheet__titlerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sheet__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sheet__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
}
.sheet__preview {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-md);
  padding: 26px;
  min-height: 100%;
}

/* ---------- 15. Modal ---------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal__card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 26px;
  background: var(--glass-raise);
  animation: popover-in var(--dur-2) var(--ease);
}
.modal__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.modal__body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-bottom: 20px;
}
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal__area {
  height: 150px;
  margin-bottom: 16px;
  font-family: var(--font-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 13px;
}

/* ---------- 15b. Settings panel ------------------------------------------ */

.settings {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: var(--z-sheet);
  width: min(520px, 100vw);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  background: var(--glass-raise);
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease);
}
.settings--open {
  transform: none;
}
.settings__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--paper-line);
}
.settings__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.settings__title i {
  color: var(--accent);
}
.settings__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.settings__foot {
  flex-shrink: 0;
  padding: 14px 22px;
  border-top: 1px solid var(--paper-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sgroup {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sgroup__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.sgroup__title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.sgroup__hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* Font rows preview themselves, which is the only honest way to pick a face. */
.fontlist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fontopt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: var(--r-md);
  background: var(--field);
  border: 1px solid var(--field-line);
  text-align: left;
  transition: border-color var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease);
}
.fontopt:hover {
  border-color: var(--glass-border-strong);
}
.fontopt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.fontopt__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fontopt__name {
  font-size: 13.5px;
  font-weight: 700;
}
.fontopt__note {
  font-size: 11.5px;
  color: var(--ink-3);
}
.fontopt__check {
  color: var(--accent);
  font-size: 16px;
  opacity: 0;
}
.fontopt[aria-pressed="true"] .fontopt__check {
  opacity: 1;
}

.swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur-1) var(--ease), border-color var(--dur-2) var(--ease);
}
.swatch:hover {
  transform: scale(1.1);
}
.swatch[aria-pressed="true"] {
  border-color: var(--ink);
}
.swatch--custom {
  display: grid;
  place-items: center;
  background: var(--field);
  border: 1px dashed var(--ink-4);
  color: var(--ink-3);
  font-size: 14px;
  padding: 0;
}
.swatch--custom input {
  position: absolute;
  opacity: 0;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.slider {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  min-width: 0;
}
.slider__value {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wallpaper {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.wallpaper__preview {
  width: 108px;
  height: 68px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--field-line);
  background-color: var(--field);
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: 19px;
}
.wallpaper__actions {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  justify-content: center;
}

.settings__drop {
  border: 1px dashed var(--ink-4);
  border-radius: var(--r-md);
  padding: 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  transition: border-color var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease);
}
.settings__drop--over {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
}

/* Demo strip. Sits above everything so the state is never a surprise:
   what this is on the left, how to get an account on the right. */
.demobar {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-chrome) + 1);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  font-size: 13px;
  color: var(--ink-2);
  background: linear-gradient(170deg, var(--em-500), var(--em-700));
  color: var(--accent-ink);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}
.demobar__tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.demobar__tag i {
  font-size: 16px;
}
.demobar__note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.92;
}
.demobar__spacer {
  flex: 1;
  min-width: 0;
}
.demobar__cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 15px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  background: var(--accent-ink);
  color: var(--em-700);
  transition: transform var(--dur-1) var(--ease), opacity var(--dur-2) var(--ease);
}
.demobar__cta:hover {
  transform: translateY(-1px);
}
.demobar__ghost {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-ink);
  opacity: 0.85;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.demobar__ghost:hover {
  opacity: 1;
}

/* ---------- Admin dashboard ---------------------------------------------- */

.admin {
  flex: 1;
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 18px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.adminsec {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.adminsec__head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.adminsec__title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.adminsec__title i {
  color: var(--accent);
  font-size: 18px;
}

.utable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.utable th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  padding: 0 12px 8px;
  white-space: nowrap;
}
.utable th.num,
.utable td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.utable td {
  padding: 11px 12px;
  border-top: 1px solid var(--paper-line);
  vertical-align: middle;
}
.utable tbody tr:hover {
  background: var(--accent-wash);
}
.utable__name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}
.utable__actions {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}
.tablewrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  padding: 14px 4px 4px;
}

.invite {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--field);
  border: 1px solid var(--field-line);
}
.invite--used {
  opacity: 0.55;
}
.invite__code {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-family: var(--font-code, ui-monospace, monospace);
  white-space: nowrap;
}
.invite__meta {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Changelog ----------------------------------------------------- */

.credit button {
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.9;
}
.credit button:hover {
  color: var(--accent);
  opacity: 1;
}

.changelog {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 4px;
}
.release__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 9px;
}
.release__version {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.release__date {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.release__now {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--accent-wash);
  color: var(--accent);
}
.release__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.release__list li {
  display: flex;
  gap: 9px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.release__list i {
  color: var(--accent);
  font-size: 13px;
  margin-top: 4px;
  flex-shrink: 0;
}

/* ---------- 16. Toast ---------------------------------------------------- */

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: var(--z-toast);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 19px;
  max-width: min(520px, calc(100vw - 32px));
  background: var(--glass-raise);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  animation: toast-in var(--dur-3) var(--ease);
}
.toast i {
  font-size: 19px;
  flex-shrink: 0;
}
.toast--warn i {
  color: #f0b429;
}
.toast--error i {
  color: var(--danger);
}
.toast--ok i {
  color: var(--ok);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -22px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- 17. Save indicator ------------------------------------------- */

.savestate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.savestate i {
  font-size: 14px;
}
.savestate--saving i {
  animation: spin 0.9s linear infinite;
  color: var(--accent);
}
.savestate--saved i {
  color: var(--ok);
}
.savestate--error {
  color: var(--danger);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.doctitle {
  min-width: 0;
  max-width: 100%;
  padding: 5px 11px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  transition: background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.doctitle:hover {
  background: var(--field);
  border-color: var(--field-line);
}
.doctitle:focus {
  outline: none;
  background: var(--field);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* ---------- 18. Footer credit -------------------------------------------- */

.credit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
}
.credit strong {
  color: var(--ink-2);
  font-weight: 700;
}

/* ---------- 19. Responsive ----------------------------------------------- */

@media (max-width: 1024px) {
  .workspace {
    flex-direction: column;
    padding: 0 10px 10px;
  }
  .pane--notes {
    width: 100%;
    max-height: 42vh;
  }
  .pane--reader {
    min-height: 58vh;
  }
  .reader__scroll {
    padding: 24px 20px 80px;
  }
}

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14.5px;
  }
  .topbar-rail {
    padding: 8px 14px 0;
  }
  .topbar {
    padding: 8px 11px;
    gap: 8px;
  }
  .topbar__title {
    display: none;
  }
  .settings {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    inset: 6vh 0 0 0;
    width: 100%;
    transform: translateY(100%);
  }
  .settings--open {
    transform: none;
  }
  .settings__body {
    padding: 16px 16px 32px;
  }
  .library {
    padding: 10px 14px 44px;
  }
  .library__heading {
    font-size: 23px;
  }
  .library__search {
    max-width: none;
  }

  .paste-cta {
    padding: 15px 16px;
    gap: 13px;
  }
  .paste-cta__badge {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }
  .paste-cta__title {
    font-size: 15px;
  }
  .paste-cta__sub {
    font-size: 12.5px;
  }

  /* Rows reflow to two lines: identity on top, metadata underneath. */
  .docrow {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "badge main actions"
      "badge meta actions";
    row-gap: 4px;
    column-gap: 12px;
  }
  .docrow__badge {
    grid-area: badge;
  }
  .docrow__main {
    grid-area: main;
  }
  .docrow__meta {
    grid-area: meta;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .docrow__actions {
    grid-area: actions;
    opacity: 1;
    transform: none;
  }
  .docrow__excerpt {
    display: none;
  }

  .compose {
    padding: 2px 14px 30px;
  }
  .compose__card {
    padding: 20px 16px;
  }
  .auth__card {
    padding: 30px 22px 24px;
  }
  .sheet {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    inset: 8vh 0 0 0;
    width: 100%;
    transform: translateY(100%);
  }
  .sheet--open {
    transform: none;
  }
  .sheet__body {
    padding: 15px;
  }
  .sheet__preview {
    padding: 17px;
  }
  .popover {
    width: calc(100vw - 24px);
  }
}

/* On wide screens the row metadata sits inline, so the mobile-only
   wrapper must not add a second grid cell. */
@media (min-width: 641px) {
  .docrow__meta {
    display: contents;
  }
}

/* ---------- 20. Reduced motion ------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .aurora__blob {
    animation: none;
  }
  .sheet {
    transition: none;
  }
}
