:root {
  --ny-control-height: 36px;
  --ny-control-radius: 999px;
  --ny-control-icon-size: 38px;
  --ny-control-font: "DM Mono", "Cascadia Mono", Consolas, monospace;
  --ny-system-body-font: "DM Sans", Arial, sans-serif;
  --ny-mobile-gutter: 14px;
}

body {
  font-family: var(--ny-system-body-font);
}

header[data-nyarindo-shell="app"] {
  min-height: 64px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink, #eeece5) 12%, transparent);
  background: color-mix(in srgb, var(--surface, #171915) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.08);
}

html.nyarindo-node-view header[data-nyarindo-shell="app"] {
  padding-right: 88px;
}

.nyarindo-system-control {
  box-sizing: border-box;
  min-height: var(--ny-control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid color-mix(in srgb, var(--ink, #eeece5) 15%, transparent);
  border-radius: var(--ny-control-radius);
  background: color-mix(in srgb, var(--surface, #171915) 78%, transparent);
  color: var(--ink, #eeece5);
  font: 500 .625rem/1 var(--mono, var(--ny-control-font));
  letter-spacing: .045em;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition:
    transform .18s ease,
    border-color .18s ease,
    background-color .18s ease,
    color .18s ease,
    box-shadow .18s ease;
}

[data-nyarindo-flex="centered"] {
  align-items: center !important;
  align-content: center !important;
  justify-content: center !important;
}

.nyarindo-system-control:not([data-nyarindo-symbol]) {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.nyarindo-system-control:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--accent, #d2a36d) 72%, transparent);
  color: var(--ink, #eeece5);
  transform: translateY(-1px);
}

.nyarindo-system-control[data-nyarindo-control="primary"] {
  border-color: color-mix(in srgb, var(--accent, #d2a36d) 76%, transparent);
  background: var(--accent, #d2a36d);
  color: color-mix(in srgb, var(--bg, #10110f) 92%, #000);
  box-shadow:
    0 8px 22px color-mix(in srgb, var(--accent, #d2a36d) 20%, transparent),
    inset 0 1px 0 color-mix(in srgb, white 28%, transparent);
}

.nyarindo-system-control[data-nyarindo-control="primary"]:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--accent, #d2a36d) 86%, white);
  border-color: color-mix(in srgb, var(--accent, #d2a36d) 86%, white);
  box-shadow:
    0 12px 30px color-mix(in srgb, var(--accent, #d2a36d) 26%, transparent),
    inset 0 1px 0 color-mix(in srgb, white 34%, transparent);
}

.nyarindo-system-control[data-nyarindo-control="secondary"] {
  border-color: color-mix(in srgb, var(--ink, #eeece5) 15%, transparent);
  background: color-mix(in srgb, var(--surface, #171915) 64%, transparent);
}

.nyarindo-system-control[data-nyarindo-control="icon"] {
  inline-size: var(--ny-control-icon-size) !important;
  block-size: var(--ny-control-icon-size) !important;
  width: var(--ny-control-icon-size) !important;
  height: var(--ny-control-icon-size) !important;
  min-width: var(--ny-control-icon-size) !important;
  min-height: var(--ny-control-icon-size) !important;
  max-width: var(--ny-control-icon-size) !important;
  max-height: var(--ny-control-icon-size) !important;
  flex: 0 0 var(--ny-control-icon-size) !important;
  align-self: center;
  justify-self: center;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  font-size: .75rem;
}

.nyarindo-system-control[data-nyarindo-symbol] {
  width: var(--ny-control-icon-size);
  min-width: var(--ny-control-icon-size);
  height: var(--ny-control-icon-size);
  min-height: var(--ny-control-icon-size);
  padding: 0;
  border-radius: 50%;
  font-size: 0;
}

.nyarindo-system-control[data-nyarindo-symbol]::before {
  content: attr(data-nyarindo-symbol);
  display: grid;
  place-items: center;
  width: 100%;
  text-align: center;
  color: currentColor;
  font: 700 1rem/1 "Segoe UI Symbol", "Noto Sans Symbols 2", var(--ny-control-font);
}

.nyarindo-system-control[data-nyarindo-symbol] > * {
  display: none;
}

.nyarindo-system-palette-control {
  width: var(--ny-control-icon-size) !important;
  min-width: var(--ny-control-icon-size) !important;
  height: var(--ny-control-icon-size) !important;
  min-height: var(--ny-control-icon-size) !important;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--ink, #eeece5) 15%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface, #171915) 78%, transparent);
  color: var(--ink, #eeece5);
  cursor: pointer;
  list-style: none;
  backdrop-filter: blur(12px);
}

.nyarindo-system-palette-control::-webkit-details-marker {
  display: none;
}

.nyarindo-universal-palette {
  position: relative;
}

.nyarindo-system-palette-orbit {
  position: relative;
  width: 25px;
  height: 25px;
}

.nyarindo-system-palette-orbit i,
.nyarindo-system-palette-panel button {
  position: absolute;
  border: 0;
  border-radius: 50%;
}

.nyarindo-system-palette-orbit i {
  width: 7px;
  height: 7px;
}

.nyarindo-system-palette-orbit i:nth-child(1) { left: 9px; top: 0; background: var(--nyarindo-swatch-forest); }
.nyarindo-system-palette-orbit i:nth-child(2) { right: 1px; top: 6px; background: var(--nyarindo-swatch-ocean); }
.nyarindo-system-palette-orbit i:nth-child(3) { right: 4px; bottom: 1px; background: var(--nyarindo-swatch-amethyst); }
.nyarindo-system-palette-orbit i:nth-child(4) { left: 4px; bottom: 1px; background: var(--nyarindo-swatch-ember); }
.nyarindo-system-palette-orbit i:nth-child(5) { left: 1px; top: 6px; background: var(--nyarindo-swatch-rose); }
.nyarindo-system-palette-orbit i:nth-child(6) { left: 9px; top: 9px; background: var(--nyarindo-swatch-slate); }

.nyarindo-system-palette-panel {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line, rgba(255,255,255,.16));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface, #171915) 94%, transparent);
  box-shadow: 0 18px 45px rgba(0,0,0,.3);
  backdrop-filter: blur(20px);
}

.nyarindo-system-palette-panel button {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
}

.nyarindo-system-palette-panel button[data-palette-choice="forest"] { background: var(--nyarindo-swatch-forest); }
.nyarindo-system-palette-panel button[data-palette-choice="ocean"] { background: var(--nyarindo-swatch-ocean); }
.nyarindo-system-palette-panel button[data-palette-choice="amethyst"] { background: var(--nyarindo-swatch-amethyst); }
.nyarindo-system-palette-panel button[data-palette-choice="ember"] { background: var(--nyarindo-swatch-ember); }
.nyarindo-system-palette-panel button[data-palette-choice="rose"] { background: var(--nyarindo-swatch-rose); }
.nyarindo-system-palette-panel button[data-palette-choice="slate"] { background: var(--nyarindo-swatch-slate); }

[data-palette-choice],
button[data-palette] {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
}

.nyarindo-system-blob {
  --nyarindo-blob-size: 54px;
  width: var(--nyarindo-blob-size) !important;
  height: var(--nyarindo-blob-size) !important;
  min-width: var(--nyarindo-blob-size) !important;
  min-height: var(--nyarindo-blob-size) !important;
  max-width: var(--nyarindo-blob-size) !important;
  max-height: var(--nyarindo-blob-size) !important;
  touch-action: manipulation;
  transition: opacity .2s ease, filter .2s ease, transform .2s ease;
}

html.nyarindo-node-view .nyarindo-system-blob {
  --nyarindo-blob-size: 48px;
}

:is(
  body.writer-focus-mode .writer-focus-blob,
  body.immersive .lyric-edit-blob,
  .player-media-shell.video-focus-fallback .video-master-blob
) {
  --nyarindo-blob-size: 48px;
}

html.nyarindo-node-view :is(
  body.writer-focus-mode .writer-focus-blob,
  body.immersive .lyric-edit-blob,
  .player-media-shell.video-focus-fallback .video-master-blob
) {
  --nyarindo-blob-size: 42px;
}

.nyarindo-system-blob:not(.is-dormant) {
  filter:
    drop-shadow(0 0 7px rgba(74, 169, 255, .5))
    drop-shadow(0 0 20px rgba(54, 149, 255, .42));
  animation: nyarindo-blob-awake 2.6s ease-in-out infinite;
}

.nyarindo-system-blob[aria-expanded="true"]:not(.is-dormant) {
  filter:
    drop-shadow(0 0 7px rgba(255, 78, 78, .52))
    drop-shadow(0 0 22px rgba(255, 64, 64, .38));
}

.nyarindo-system-blob.is-dormant {
  opacity: .74;
  filter: none;
  animation: none;
}

.nyarindo-system-blob:focus-visible {
  outline: 2px solid var(--accent, #d2a36d);
  outline-offset: 4px;
}

@keyframes nyarindo-blob-awake {
  50% {
    filter:
      drop-shadow(0 0 11px rgba(74, 169, 255, .62))
      drop-shadow(0 0 30px rgba(54, 149, 255, .48));
  }
}

.nyarindo-system-blob[aria-expanded="true"]:not(.is-dormant) {
  animation-name: nyarindo-blob-awake-red;
}

@keyframes nyarindo-blob-awake-red {
  50% {
    filter:
      drop-shadow(0 0 11px rgba(255, 78, 78, .64))
      drop-shadow(0 0 30px rgba(255, 64, 64, .44));
  }
}

@media (max-width: 620px) {
  .nyarindo-system-blob {
    --nyarindo-blob-size: 46px;
  }

  html.nyarindo-node-view .nyarindo-system-blob {
    --nyarindo-blob-size: 40px;
  }

  :is(
    body.writer-focus-mode .writer-focus-blob,
    body.immersive .lyric-edit-blob,
    .player-media-shell.video-focus-fallback .video-master-blob
  ) {
    --nyarindo-blob-size: 40px;
  }

  html.nyarindo-node-view :is(
    body.writer-focus-mode .writer-focus-blob,
    body.immersive .lyric-edit-blob,
    .player-media-shell.video-focus-fallback .video-master-blob
  ) {
    --nyarindo-blob-size: 36px;
  }
}

header a[href],
nav a[href],
header summary {
  min-width: 32px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nyarindo-system-control[data-nyarindo-control="tab"] {
  min-height: 31px;
  padding: 0 12px;
  border-radius: var(--ny-control-radius);
  background: transparent;
  color: color-mix(in srgb, var(--ink, #eeece5) 62%, transparent);
}

.nyarindo-system-control[data-nyarindo-control="tab"][aria-selected="true"],
.nyarindo-system-control[data-nyarindo-control="tab"].is-active {
  border-color: color-mix(in srgb, var(--accent, #d2a36d) 65%, transparent);
  background: color-mix(in srgb, var(--accent, #d2a36d) 14%, var(--surface, #171915));
  color: var(--ink, #eeece5);
}

.nyarindo-system-control:disabled,
.nyarindo-system-control[aria-disabled="true"] {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
}

:where(button, a, summary, input, textarea, select):focus-visible {
  outline: 2px solid var(--accent, #d2a36d);
  outline-offset: 3px;
}

.dialog-actions,
.model-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions > button,
.model-actions > button {
  width: auto;
  flex: 0 1 auto;
}

@media (max-width: 620px) {
  :root {
    --ny-control-height: 33px;
    --ny-control-icon-size: 35px;
  }

  .nyarindo-system-control {
    min-height: var(--ny-control-height);
    padding-inline: 11px;
    font-size: .5625rem;
    letter-spacing: .035em;
  }

  .nyarindo-system-control[data-nyarindo-control="icon"] {
    inline-size: var(--ny-control-icon-size) !important;
    block-size: var(--ny-control-icon-size) !important;
    width: var(--ny-control-icon-size) !important;
    height: var(--ny-control-icon-size) !important;
    min-width: var(--ny-control-icon-size) !important;
    min-height: var(--ny-control-icon-size) !important;
    max-width: var(--ny-control-icon-size) !important;
    max-height: var(--ny-control-icon-size) !important;
    flex: 0 0 var(--ny-control-icon-size) !important;
    padding: 0;
  }

  .nyarindo-system-control[data-nyarindo-symbol] {
    width: var(--ny-control-icon-size);
    min-width: var(--ny-control-icon-size);
    height: var(--ny-control-icon-size);
    min-height: var(--ny-control-icon-size);
    padding: 0;
  }

  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  :where(
    .hub-header,
    .topbar,
    .drift-header,
    .site-head,
    .library-header,
    .experiment-header,
    .writer-header,
    .light-header
  ) {
    padding-left: var(--ny-mobile-gutter);
    padding-right: var(--ny-mobile-gutter);
  }

  :where(
    .app-field,
    .hero,
    .section-wrap,
    .books-section,
    .social-footer,
    .approach,
    .closing,
    .chapter,
    .messages
  ) {
    padding-left: var(--ny-mobile-gutter) !important;
    padding-right: var(--ny-mobile-gutter) !important;
  }

  :where(img, svg, canvas, video) {
    max-width: 100%;
  }

  body .drift-header {
    min-height: 104px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
    align-content: center;
    gap: 7px 10px;
    padding-block: 8px;
  }

  .drift-header > .wordmark {
    grid-area: brand;
    min-width: 0;
  }

  .drift-header > nav {
    grid-area: nav;
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px 12px;
  }

  .drift-header > nav :is(a, button) {
    padding-inline: 2px;
    font-size: 8px;
    letter-spacing: .08em;
  }

  .drift-header > .header-actions {
    grid-area: actions;
    min-width: 0;
    justify-self: end;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .drift-rail .rail-tool > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body .player-shell .player-service-orbit {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
  }

  body .player-service-orbit .service-orbit-tool {
    position: relative;
    inset: auto;
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transform: none;
  }

  body .player-service-orbit .service-orbit-tool svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
  }

  body .player-service-orbit .service-orbit-tool span {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    font-size: 8px;
    white-space: nowrap;
  }

  #publicTrackSyncTitle {
    overflow: visible;
    line-height: 1.22;
  }

  .document-entry strong {
    overflow: visible;
    white-space: normal;
    line-height: 1.3;
  }

  .document-row,
  .document-entry {
    min-width: 0;
  }

  .support-cta,
  .contact-link,
  .text-link,
  .back-top {
    width: auto;
    max-width: 100%;
    height: auto;
    min-height: 40px;
    white-space: normal !important;
    overflow-wrap: anywhere;
    text-align: center;
  }

  .nyarindo-system-palette-control {
    width: var(--ny-control-icon-size) !important;
    min-width: var(--ny-control-icon-size) !important;
    height: var(--ny-control-icon-size) !important;
    min-height: var(--ny-control-icon-size) !important;
    padding: 0;
  }

  [data-palette-choice],
  button[data-palette] {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
  }

  header a[href],
  nav a[href],
  header summary {
    min-width: 32px;
    min-height: 38px;
  }

  .dialog-actions,
  .model-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dialog-actions > button,
  .model-actions > button {
    width: auto;
    flex: 1 1 auto;
  }
}

.dialog-actions > .nyarindo-system-control[data-nyarindo-symbol],
.model-actions > .nyarindo-system-control[data-nyarindo-symbol] {
  width: var(--ny-control-icon-size);
  min-width: var(--ny-control-icon-size);
  flex: 0 0 var(--ny-control-icon-size);
  padding: 0;
}

@media (prefers-reduced-motion: reduce) {
  .nyarindo-system-control {
    transition: none;
  }
}

.nyarindo-button-tooltip {
  position: fixed;
  z-index: 5000;
  max-width: min(280px, calc(100vw - 20px));
  padding: 7px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink, #edf3eb) 94%, transparent);
  color: var(--bg, #091311);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
  font: 9px/1.4 var(--mono, ui-monospace, monospace);
  letter-spacing: .025em;
  pointer-events: none;
  transform: translateX(-50%);
}
