:root {
  --writer-paper: #f7f4eb;
  --writer-paper-ink: #24231f;
  --writer-shadow: 0 24px 70px rgba(0, 0, 0, .28);
  --writer-accent: var(--accent);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  min-height: 100svh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  overflow: hidden;
  background:
    radial-gradient(circle at 84% 0, rgba(var(--accent-rgb), .13), transparent 31%),
    var(--bg);
  color: var(--ink);
  font-family: "DM Sans", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

button,
summary {
  color: inherit;
}

.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;
}

.writer-header {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}

.writer-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}
.writer-titlebar {
  min-width: 0;
}
.writer-header-actions > [hidden] {
  display: none !important;
}

.writer-brand img {
  display: block;
  width: 38px;
  height: 38px;
}

.writer-brand span {
  display: grid;
  line-height: 1;
}

.writer-brand b {
  font: 700 11px/1 var(--sans);
  letter-spacing: .08em;
}

.writer-brand small {
  margin-top: 4px;
  color: var(--muted);
  font: 7px/1 var(--mono);
  letter-spacing: .16em;
}

.writer-header-center {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.document-title {
  width: min(390px, 42vw);
  min-width: 0;
  height: 34px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 500 13px var(--sans);
  text-align: center;
}

.document-title:hover,
.document-title:focus {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface2) 78%, transparent);
  outline: none;
}

.save-state {
  flex: none;
  color: var(--muted);
  font: 7px var(--mono);
  letter-spacing: .04em;
}

.writer-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-icon,
.export-button,
.writer-palette > summary {
  min-width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface2) 72%, transparent);
  color: var(--ink);
  cursor: pointer;
}

.header-icon {
  font: 17px var(--serif);
}

.export-button {
  min-width: 70px;
  background: var(--accent);
  color: color-mix(in srgb, var(--bg) 92%, #000);
  font: 600 9px var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-icon:is(:hover, :focus-visible),
.export-button:is(:hover, :focus-visible),
.writer-palette > summary:is(:hover, :focus-visible) {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}

.writer-palette {
  position: relative;
}

.writer-palette > summary {
  list-style: none;
}

.writer-palette > summary::-webkit-details-marker {
  display: none;
}

.writer-palette-orbit {
  position: relative;
  width: 23px;
  height: 23px;
}

.writer-palette-orbit i,
.writer-palette-panel button {
  position: absolute;
  border: 0;
  border-radius: 50%;
}

.writer-palette-orbit i {
  width: 6px;
  height: 6px;
}

.writer-palette-orbit i:nth-child(1) { left: 8px; top: 0; background: var(--nyarindo-swatch-forest); }
.writer-palette-orbit i:nth-child(2) { right: 1px; top: 5px; background: var(--nyarindo-swatch-ocean); }
.writer-palette-orbit i:nth-child(3) { right: 3px; bottom: 1px; background: var(--nyarindo-swatch-amethyst); }
.writer-palette-orbit i:nth-child(4) { left: 3px; bottom: 1px; background: var(--nyarindo-swatch-ember); }
.writer-palette-orbit i:nth-child(5) { left: 1px; top: 5px; background: var(--nyarindo-swatch-rose); }
.writer-palette-orbit i:nth-child(6) { left: 8px; top: 8px; background: var(--nyarindo-swatch-slate); }

.writer-palette-panel {
  position: absolute;
  z-index: 40;
  top: 44px;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--writer-shadow);
}

.writer-palette-panel button {
  position: relative;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.writer-palette-panel button[data-palette-choice="forest"] { background: var(--nyarindo-swatch-forest); }
.writer-palette-panel button[data-palette-choice="ocean"] { background: var(--nyarindo-swatch-ocean); }
.writer-palette-panel button[data-palette-choice="amethyst"] { background: var(--nyarindo-swatch-amethyst); }
.writer-palette-panel button[data-palette-choice="ember"] { background: var(--nyarindo-swatch-ember); }
.writer-palette-panel button[data-palette-choice="rose"] { background: var(--nyarindo-swatch-rose); }
.writer-palette-panel button[data-palette-choice="slate"] { background: var(--nyarindo-swatch-slate); }

.writer-palette-panel button[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

.writer-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  overflow: hidden;
}

.document-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.document-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
}

.document-panel-head > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.document-panel-head span {
  color: var(--muted);
  font: 7px var(--mono);
  letter-spacing: .1em;
}

.document-panel-head strong {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), .14);
  color: var(--accent);
  font: 8px var(--mono);
  text-align: center;
}

.document-panel-head button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.document-list {
  overflow-y: auto;
  padding: 8px;
}

.document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: stretch;
  gap: 3px;
  margin-bottom: 5px;
}

.document-entry {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.document-entry:is(:hover, :focus-visible, .is-current) {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
  outline: none;
}

.document-row:is(:hover, :focus-within) .document-entry:not(.is-current) {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}

.document-delete {
  position: relative;
  width: 30px;
  min-height: 30px;
  align-self: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  cursor: pointer;
  opacity: .38;
  transition: opacity .18s ease, color .18s ease, background-color .18s ease, border-color .18s ease;
}

.document-row:is(:hover, :focus-within) .document-delete,
.document-delete:focus-visible {
  opacity: 1;
}

.document-delete:hover,
.document-delete:focus-visible {
  border-color: rgba(211, 77, 77, .38);
  background: rgba(211, 77, 77, .1);
  color: #c74141;
  outline: none;
}

.document-delete span,
.document-delete span::before,
.document-delete span::after {
  position: absolute;
  content: "";
}

.document-delete span {
  top: 50%;
  left: 50%;
  width: 11px;
  height: 10px;
  border: 1px solid currentColor;
  border-top: 0;
  border-radius: 0 0 2px 2px;
  transform: translate(-50%, -42%);
}

.document-delete span::before {
  top: -3px;
  left: -2px;
  width: 13px;
  height: 1px;
  background: currentColor;
}

.document-delete span::after {
  top: -5px;
  left: 3px;
  width: 5px;
  height: 2px;
  border: 1px solid currentColor;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
}

.document-entry strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-entry small {
  color: var(--muted);
  font: 7px var(--mono);
}

.document-panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 9px;
  border-top: 1px solid var(--line);
}

.document-panel-actions :is(button, label) {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: 7px var(--mono);
  cursor: pointer;
}

.import-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.editor-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 28px;
  overflow: hidden;
}

.writer-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  scrollbar-width: thin;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-right: 7px;
  border-right: 1px solid var(--line);
}

.tool-group:last-child {
  border-right: 0;
}

.writer-toolbar :is(button, select, .color-tool, .file-tool) {
  min-width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: 10px var(--mono);
}

.writer-toolbar button,
.writer-toolbar label,
.writer-toolbar select {
  cursor: pointer;
}

.writer-toolbar button {
  display: grid;
  place-items: center;
  padding: 0 7px;
}

.writer-toolbar select {
  min-width: 92px;
  padding: 0 7px;
  background: var(--surface2);
}

.writer-toolbar :is(button, select, label):is(:hover, :focus-visible) {
  border-color: var(--line);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
  outline: none;
}

.writer-toolbar button.is-active {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: rgba(var(--accent-rgb), .14);
  color: var(--accent);
}

.color-tool,
.file-tool {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0 6px;
}

.color-tool input,
.file-tool input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.highlight-tool {
  color: #f1d04e;
}

.document-viewport {
  min-height: 0;
  overflow: auto;
  padding: clamp(16px, 3vw, 34px);
  background:
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    color-mix(in srgb, var(--bg) 90%, #000);
  background-size: 24px 24px;
}

.document-page {
  width: min(790px, 100%);
  min-height: 1040px;
  margin: 0 auto;
  padding: clamp(50px, 7vw, 92px) clamp(34px, 7vw, 88px);
  border: 1px solid rgba(0, 0, 0, .08);
  background: var(--writer-paper);
  color: var(--writer-paper-ink);
  box-shadow: var(--writer-shadow);
  font: 17px/1.82 Georgia, "Times New Roman", serif;
  outline: none;
}

.document-page:empty::before {
  content: attr(data-placeholder);
  color: rgba(35, 35, 30, .36);
  pointer-events: none;
}

.document-page :is(h1, h2, h3, h4) {
  line-height: 1.08;
  letter-spacing: -.035em;
  color: #1d261f;
}

.document-page h1 { margin: 0 0 32px; font-size: 52px; }
.document-page h2 { margin: 2em 0 .65em; font-size: 35px; }
.document-page h3 { margin: 1.8em 0 .55em; font-size: 27px; }
.document-page h4 { margin: 1.5em 0 .5em; font-size: 21px; }
.document-page p { margin: 0 0 1em; }
.document-page a { color: #276c84; text-underline-offset: 3px; }
.document-page blockquote { margin: 1.4em 0; padding: .25em 0 .25em 1.1em; border-left: 3px solid #9a6734; color: #554d44; }
.document-page pre { padding: 14px 16px; overflow-x: auto; background: #20251f; color: #f1eee4; font: 13px/1.6 "DM Mono", monospace; white-space: pre-wrap; }
.document-page img { max-width: 100%; height: auto; margin: 1em auto; display: block; }
.document-page table { width: 100%; margin: 1.2em 0; border-collapse: collapse; }
.document-page td, .document-page th { min-width: 50px; padding: 8px; border: 1px solid rgba(35,35,30,.28); vertical-align: top; }

.writer-footer {
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 7px var(--mono);
  letter-spacing: .035em;
}

.writer-footer span:last-child {
  margin-left: auto;
}

.writer-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100svh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--writer-shadow);
  overflow: auto;
}

.writer-dialog::backdrop {
  background: rgba(3, 9, 7, .72);
  backdrop-filter: blur(10px);
}

.dialog-sheet {
  position: relative;
  display: grid;
  gap: 13px;
  padding: clamp(24px, 5vw, 40px);
}

.dialog-sheet h2 {
  margin: 0 0 4px;
  font: 400 clamp(34px, 6vw, 52px)/.98 var(--serif);
  letter-spacing: -.045em;
}

.dialog-kicker {
  margin: 0;
  color: var(--accent);
  font: 8px var(--mono);
  letter-spacing: .13em;
}

.dialog-sheet label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font: 8px var(--mono);
  letter-spacing: .04em;
}

.dialog-sheet input {
  height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface2);
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.dialog-actions button,
.export-grid button {
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface2);
  color: var(--ink);
  cursor: pointer;
}

.dialog-actions button:first-child {
  background: var(--accent);
  color: var(--bg);
}

.quiet-dialog-button {
  background: transparent !important;
  color: var(--muted) !important;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.export-grid button {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 70px;
  text-align: left;
}

.export-grid b {
  color: var(--accent);
  font: 11px var(--mono);
}

.export-grid span,
.dialog-note {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.dialog-note {
  margin: 2px 0 0;
}

.writer-toast {
  position: fixed;
  z-index: 80;
  right: 17px;
  bottom: 17px;
  max-width: min(360px, calc(100vw - 34px));
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.writer-toast.show {
  opacity: 1;
  transform: none;
}

.writer-tooltip {
  position: fixed;
  z-index: 220;
  max-width: min(240px, calc(100vw - 20px));
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(12, 16, 15, .94);
  color: #f5f1e7;
  box-shadow: 0 9px 24px rgba(0, 0, 0, .28);
  font: 8px/1.35 var(--mono);
  letter-spacing: .035em;
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.writer-tooltip[hidden] {
  display: none;
}

html[data-theme="light"] .writer-tooltip {
  border-color: rgba(20, 30, 24, .2);
  background: rgba(249, 247, 239, .97);
  color: #242b25;
  box-shadow: 0 9px 24px rgba(35, 45, 38, .16);
}

.writer-focus-blob {
  position: fixed;
  z-index: 150;
  right: 18px;
  left: auto;
  bottom: 18px;
  width: 52px;
  height: 52px;
  display: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  isolation: isolate;
  transform: none;
}

.writer-focus-aura,
.writer-focus-core {
  position: absolute;
  border-radius: 50%;
}

.writer-focus-aura {
  inset: -12px;
  background: radial-gradient(circle, rgba(65, 157, 255, .7), rgba(65, 157, 255, .16) 48%, transparent 72%);
  filter: blur(7px);
  animation: writer-focus-breathe 2.8s ease-in-out infinite;
}

.writer-focus-core {
  inset: 7px;
  border: 1px solid rgba(220, 240, 255, .72);
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .55), transparent 24%),
    linear-gradient(145deg, #4aa9ff, #155fc6);
  box-shadow: 0 0 16px rgba(54, 149, 255, .62);
}

.writer-focus-blob.is-expanded .writer-focus-aura {
  background: radial-gradient(circle, rgba(255, 72, 72, .72), rgba(255, 72, 72, .16) 48%, transparent 72%);
  animation: none;
}

.writer-focus-blob.is-expanded .writer-focus-core {
  border-color: rgba(255, 222, 222, .76);
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .58), transparent 24%),
    linear-gradient(145deg, #ff5d5d, #b51f2c);
  box-shadow: 0 0 16px rgba(255, 64, 64, .62);
}

.writer-focus-blob.is-dormant .writer-focus-aura {
  display: none;
}

.writer-focus-blob.is-dormant .writer-focus-core {
  background: transparent;
  box-shadow: none;
}

body.writer-focus-mode {
  overflow: hidden;
}

body.writer-focus-mode .writer-focus-blob {
  display: grid;
  place-items: center;
}

body.writer-focus-mode .writer-header,
body.writer-focus-mode .document-panel,
body.writer-focus-mode .writer-toolbar,
body.writer-focus-mode .writer-footer {
  display: none;
}

body.writer-focus-mode.writer-controls-visible .writer-header {
  position: fixed;
  z-index: 66;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
}

body.writer-focus-mode.writer-controls-visible .writer-toolbar {
  position: fixed;
  z-index: 66;
  top: 58px;
  right: 0;
  left: 0;
  display: flex;
}

body.writer-focus-mode.writer-controls-visible .document-panel.is-open {
  position: fixed;
  z-index: 65;
  top: 58px;
  bottom: 0;
  left: 0;
  width: min(285px, 86vw);
  display: grid;
  box-shadow: 16px 0 46px rgba(0, 0, 0, .3);
}

body.writer-focus-mode .writer-workspace {
  display: block;
  height: 100svh;
}

body.writer-focus-mode .editor-shell {
  display: block;
  height: 100svh;
}

body.writer-focus-mode .document-viewport {
  height: 100svh;
  padding: 0;
  overflow: auto;
  background: var(--writer-paper);
}

body.writer-focus-mode .document-page {
  width: 100%;
  min-height: 100svh;
  margin: 0;
  padding: clamp(54px, 9vw, 150px) clamp(30px, 12vw, 210px);
  border: 0;
  box-shadow: none;
}

body.writer-focus-mode.writer-controls-visible .document-viewport {
  padding-top: 104px;
}

@keyframes writer-focus-breathe {
  0%,
  100% {
    opacity: .68;
    transform: scale(.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.13);
  }
}

@media (max-width: 760px) {
  .writer-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 7px;
    padding: 7px 9px;
  }

  .writer-brand span,
  .save-state,
  .writer-palette {
    display: none;
  }

  .writer-brand img {
    width: 34px;
    height: 34px;
  }

  .writer-header-center {
    justify-content: stretch;
  }

  .document-title {
    width: 100%;
    text-align: left;
  }

  .writer-workspace {
    grid-template-columns: 1fr;
  }

  .document-panel {
    position: fixed;
    z-index: 50;
    top: 58px;
    bottom: 0;
    left: 0;
    width: min(285px, 86vw);
    transform: translateX(-103%);
    box-shadow: 16px 0 46px rgba(0, 0, 0, .32);
    transition: transform .24s ease;
  }

  .document-panel.is-open {
    transform: none;
  }

  .document-viewport {
    padding: 10px;
  }

  .document-page {
    min-height: calc(100svh - 160px);
    padding: 44px 26px;
    font-size: 16px;
  }

  .document-page h1 {
    font-size: 38px;
  }

  .writer-footer span:nth-child(2),
  .writer-footer span:last-child {
    display: none;
  }
}

@media (max-width: 430px) {
  .export-button {
    min-width: 54px;
    padding-inline: 6px;
    font-size: 7px;
  }

  .writer-header-actions {
    gap: 3px;
  }

  .header-icon,
  .export-button {
    height: 34px;
  }

  .export-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: auto;
    margin: 20mm;
  }

  body > :not(.writer-workspace),
  .writer-toolbar,
  .writer-footer,
  .document-panel {
    display: none !important;
  }

  html,
  body,
  .writer-workspace,
  .editor-shell,
  .document-viewport {
    display: block;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  .document-viewport {
    padding: 0;
  }

  .document-page {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    color: #111;
  }
}

.writer-skin-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font: 7px var(--mono);
}

.writer-skin-picker select {
  min-height: 34px;
  max-width: 150px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface2) 72%, transparent);
  color: var(--ink);
  font: 8px var(--mono);
}

body {
  --writer-ui-accent: #2b579a;
  --writer-ribbon-bg: color-mix(in srgb, var(--surface) 92%, #242424);
  --writer-ribbon-tab: color-mix(in srgb, var(--surface2) 94%, #202020);
}

body[data-writer-skin="pages"] {
  --writer-ui-accent: #b98243;
  --writer-ribbon-bg: color-mix(in srgb, var(--surface) 92%, #3a342c);
}

body[data-writer-skin="libreoffice"] {
  --writer-ui-accent: #3b7f48;
  --writer-ribbon-bg: color-mix(in srgb, var(--surface) 92%, #3a3d38);
}

body[data-writer-skin="nyarindo"] {
  --writer-ui-accent: #4aa9ff;
  --writer-ribbon-bg: color-mix(in srgb, var(--surface) 88%, transparent);
}

body[data-writer-skin="word"] .writer-header {
  border-bottom-color: color-mix(in srgb, #2b579a 36%, var(--line));
}

body[data-writer-skin="pages"] .writer-header {
  background: color-mix(in srgb, #d9c8ad 6%, var(--surface));
}

body[data-writer-skin="libreoffice"] .writer-header {
  border-bottom: 3px solid color-mix(in srgb, #3b7f48 58%, var(--line));
}

body[data-writer-skin="nyarindo"] .writer-header {
  background:
    radial-gradient(circle at 8% 0, rgba(74, 169, 255, 12%), transparent 34%),
    color-mix(in srgb, var(--surface) 90%, transparent);
}

.writer-ribbon {
  display: block;
  padding: 0;
  overflow: visible;
  background: var(--writer-ribbon-bg);
}

.writer-ribbon-tabs {
  min-width: 0;
  display: flex;
  align-items: end;
  gap: 1px;
  min-height: 31px;
  padding: 0 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--writer-ribbon-tab);
  scrollbar-width: none;
}

.writer-ribbon-tabs::-webkit-scrollbar {
  display: none;
}

.writer-ribbon .writer-ribbon-tabs button {
  min-width: max-content;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 5px 5px 0 0;
  background: transparent;
  color: color-mix(in srgb, var(--ink) 80%, transparent);
  font: 8px var(--mono);
  cursor: pointer;
}

.writer-ribbon .writer-ribbon-tabs button:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  outline: none;
}

.writer-ribbon .writer-ribbon-tabs button[aria-selected="true"] {
  border-bottom-color: var(--writer-ui-accent);
  background: var(--writer-ribbon-bg);
  color: var(--ink);
}

.writer-ribbon-panels {
  min-width: 0;
  min-height: 105px;
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.writer-ribbon-panel {
  min-width: max-content;
  min-height: 105px;
  display: none;
  align-items: stretch;
  padding: 7px 9px 5px;
}

.writer-ribbon-panel.is-active {
  display: flex;
}

.ribbon-group {
  min-width: max-content;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 4px;
  padding: 2px 10px 4px;
  border-right: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}

.ribbon-group:last-child {
  border-right: 0;
}

.ribbon-group > small {
  color: color-mix(in srgb, var(--ink) 52%, transparent);
  font: 7px var(--mono);
  text-align: center;
}

.ribbon-command-row {
  display: flex;
  align-items: center;
  align-content: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px;
}

.writer-ribbon :is(button, select, .color-tool, .file-tool) {
  min-width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: 9px var(--mono);
}

.writer-ribbon :is(button, select, .color-tool, .file-tool):is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--writer-ui-accent) 42%, var(--line));
  background: color-mix(in srgb, var(--writer-ui-accent) 10%, transparent);
  outline: none;
}

.writer-ribbon :is(button, label, select) {
  cursor: pointer;
}

.writer-ribbon select {
  min-width: 105px;
  padding: 0 7px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.writer-ribbon .ribbon-large {
  width: 58px;
  height: 54px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 4px;
  text-align: center;
}

.writer-ribbon .ribbon-large b {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  font: 700 18px/1 var(--sans);
}

.writer-ribbon .ribbon-large span {
  font: 7px/1.1 var(--mono);
}

.ribbon-styles {
  min-width: 310px;
}

.ribbon-style-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.writer-ribbon .ribbon-style-row button {
  min-width: 72px;
  height: 50px;
  padding: 5px 8px;
  border-color: color-mix(in srgb, var(--ink) 13%, transparent);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  font: 10px Georgia, serif;
}

.writer-ribbon button.is-active {
  border-color: var(--writer-ui-accent);
  background: color-mix(in srgb, var(--writer-ui-accent) 15%, transparent);
  color: var(--ink);
}

body[data-writer-skin="pages"] .writer-ribbon {
  background:
    linear-gradient(180deg, color-mix(in srgb, #ffffff 8%, transparent), transparent),
    var(--writer-ribbon-bg);
}

body[data-writer-skin="pages"] .writer-ribbon-tabs {
  padding-inline: 14px;
}

body[data-writer-skin="pages"] .writer-ribbon .writer-ribbon-tabs button {
  border-radius: 999px;
  border-bottom: 0;
}

body[data-writer-skin="pages"] .writer-ribbon .writer-ribbon-tabs button[aria-selected="true"] {
  background: color-mix(in srgb, var(--writer-ui-accent) 17%, transparent);
}

body[data-writer-skin="pages"] .ribbon-group {
  border-right-color: color-mix(in srgb, var(--writer-ui-accent) 18%, transparent);
}

body[data-writer-skin="libreoffice"] .writer-ribbon-panels {
  min-height: 96px;
}

body[data-writer-skin="libreoffice"] .writer-ribbon-panel {
  min-height: 96px;
}

body[data-writer-skin="nyarindo"] .writer-ribbon {
  background:
    radial-gradient(circle at 88% 0, rgba(74, 169, 255, 12%), transparent 28%),
    var(--writer-ribbon-bg);
}

body[data-writer-skin="nyarindo"] .ribbon-group {
  border-right-color: color-mix(in srgb, #4aa9ff 18%, transparent);
}

body[data-writer-page-width="narrow"] .document-page {
  width: min(640px, 100%);
}

body[data-writer-page-width="normal"] .document-page {
  width: min(790px, 100%);
}

body[data-writer-page-width="wide"] .document-page {
  width: min(980px, 100%);
}

.document-page hr[data-page-break] {
  height: 32px;
  border: 0;
  border-top: 1px dashed rgba(35, 35, 30, .34);
}

@media (max-width: 760px) {
  .writer-skin-picker {
    display: none;
  }

  .writer-ribbon-tabs {
    padding-inline: 4px;
  }

  .writer-ribbon .writer-ribbon-tabs button {
    padding-inline: 9px;
  }

  .writer-ribbon-panels,
  .writer-ribbon-panel {
    min-height: 76px;
  }

  .writer-ribbon-panel {
    padding-block: 4px;
  }

  .ribbon-group {
    padding-inline: 7px;
  }

  .ribbon-group > small {
    display: none;
  }

  .writer-ribbon .ribbon-large {
    height: 48px;
  }

  .ribbon-styles {
    min-width: 260px;
  }

  .writer-ribbon .ribbon-style-row button {
    min-width: 60px;
    height: 43px;
  }
}

body.writer-focus-mode.writer-controls-visible .writer-toolbar {
  display: block;
}

body.writer-focus-mode.writer-controls-visible .document-viewport {
  padding-top: 205px;
}

@media (prefers-reduced-motion: reduce) {
  .document-panel,
  .writer-toast {
    transition: none;
  }
}
