@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/golos-cyr-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/golos-lat-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/golos-cyr-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/golos-lat-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/golos-cyr-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/golos-lat-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/literata-cyr-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/literata-lat-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/literata-cyr-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/literata-lat-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --desk: #221e2c;
  --side: #282433;
  --paper: #322d3e;
  --ink: #e6e0ee;
  --muted: #b7adc4;
  --line: #4a4458;
  --accent: #a394c4;
  --accent-deep: #8f80b0;
  --on-accent: #f4f0f8;
  --fault: #c9a0ae;
  --glass-line: rgba(186, 162, 255, 0.32);
  --glass: rgba(30, 23, 48, 0.5);
  --control: rgba(12, 9, 20, 0.35);
  --logo-height: 6.875rem;
  --logo-width: 12rem;
  --ui: "Golos Text", "Segoe UI", sans-serif;
  --read: "Literata", "Iowan Old Style", Palatino, serif;
  --bs-body-font-family: var(--ui);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--desk);
  --bs-border-color: var(--line);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  color-scheme: dark;
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.45;
}

button, input, textarea { font: inherit; color: inherit; }
::placeholder { color: #8d82a8; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

body::before, .glow {
  position: fixed;
  inset: -18%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 28%, rgba(163, 148, 196, 0.16), transparent 36%),
    radial-gradient(circle at 78% 72%, rgba(120, 104, 156, 0.14), transparent 40%),
    radial-gradient(circle at 48% 48%, rgba(90, 78, 120, 0.08), transparent 48%);
  animation: drift 16s ease-in-out infinite alternate;
}
body::before { content: ""; }
.glow { opacity: 0.35; }
.canvas__glow { position: absolute; }
.shell, .gate { position: relative; z-index: 1; }

/* Outside the animated workspace, the logo stays relative to the viewport. */
.site-logo {
  position: fixed;
  top: -0.1rem;
  right: 3rem;
  z-index: 60;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}
.site-logo__img {
  display: block;
  width: auto;
  height: var(--logo-height);
  max-width: var(--logo-width);
  object-fit: contain;
}
.skip {
  position: fixed;
  top: -3rem;
  left: 1rem;
  z-index: 80;
  padding: 0.4rem 0.7rem;
  background: var(--paper);
}
.skip:focus { top: 0.6rem; }

/* Every flex/grid ancestor must be allowed to shrink around the two panes. */
.shell {
  display: flex;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.side, .canvas {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: rgba(16, 12, 24, 0.58);
  backdrop-filter: blur(18px);
}
.side {
  flex: 0 0 20.5rem;
  width: 20.5rem;
  border-right: 1px solid var(--line);
  transition: transform 0.22s ease;
}
.side__body {
  flex: 1;
  min-height: 0;
  padding: 0.75rem 0.85rem 1.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}
.side__body::-webkit-scrollbar, .gate::-webkit-scrollbar { display: none; }

.hello, .side-block, .tag-filter, .tools, .tray, .account-card {
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(16px);
}
.hello {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.85rem 0.85rem 0;
  border-radius: 16px;
}
.hello__person { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.hello__text { min-width: 0; }
.hello__greet { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.02em; }
.hello__name {
  margin: 0.1rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hello__exit { display: flex; justify-content: center; }
.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.tabs {
  display: grid;
  flex: none;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  margin: 0.7rem 0.85rem 0;
  padding: 0.2rem;
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  background: rgba(30, 23, 48, 0.45);
}
.tabs__btn { min-height: 2.1rem; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.shell[data-panel="pages"] .tabs__btn[data-panel-tab="pages"],
.shell[data-panel="account"] .tabs__btn[data-panel-tab="account"] {
  background: rgba(163, 148, 196, 0.22);
  color: var(--ink);
  font-weight: 600;
}
.pages-panel, .account-panel { display: flex; flex-direction: column; gap: 0.7rem; animation: settle 0.24s ease both; }
.shell[data-panel="pages"] .account-panel,
.shell[data-panel="account"] .pages-panel { display: none; }
.side-block, .tools, .account-card { margin-bottom: 0.75rem; padding: 0.8rem; }
.tools { display: flex; flex-direction: column; }
.trays { display: flex; flex-direction: column; gap: 0.7rem; }
.tray { padding: 0.7rem 0.65rem 0.55rem; }
.side-card__title, .tray__title, .tools__label, .account-card h2, .work__caption {
  width: fit-content;
  margin: 0 0 0.55rem 0.1rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.tools__status, .account-card__now, .purge p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }
.new-page { margin: 0; }
.search { display: block; margin-top: 0.55rem; }

.side-btn, .btn-ink, .text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
}
.side-btn, .text-btn, .tag, .tags__custom, .search input, .field input {
  border: 1px solid var(--glass-line);
  background: var(--control);
}
.side-btn { width: 100%; min-height: 2.25rem; margin-top: 0.4rem; padding: 0.3rem 0.7rem; }
.side-btn:hover, .page-row a:hover { background: #2a223c; }
.side-btn--danger { color: var(--fault); }
.text-btn { min-width: 7rem; min-height: 2rem; padding: 0.2rem 0.8rem; color: var(--muted); }
.text-btn:hover { color: var(--ink); }
.btn-ink { min-height: 2.5rem; margin-top: 0.35rem; padding: 0.35rem 0.9rem; }
.side-btn--fill, .btn-ink { border: 0; background: #8d7eae; color: var(--on-accent); }
.side-btn--fill:hover, .btn-ink:hover { background: #9b8dba; color: var(--on-accent); }
.search input, .field input, .account-card input[type="file"] {
  width: 100%;
  min-width: 0;
  min-height: 2.4rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--glass-line);
  border-radius: 10px;
}
.search input:focus, .field input:focus { border-color: var(--accent); outline: none; }
.field { display: block; margin: 0.65rem 0; }
.field__name { display: block; margin-bottom: 0.25rem; color: var(--muted); font-size: 0.88rem; }
.account-card__actions { display: grid; gap: 0.35rem; }
.errorlist { margin: 0.3rem 0 0; padding: 0; color: var(--fault); font-size: 0.88rem; list-style: none; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.75rem; }
.tag-filter__row, .tags__pick, .tags__chosen { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tags {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.35rem 0 0.2rem;
  padding: 0.7rem 1.4rem 0.85rem;
  border-bottom: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(16px);
}
.tag { min-width: 2rem; min-height: 2rem; padding: 0.15rem 0.45rem; border-radius: 10px; cursor: pointer; line-height: 1.2; }
.tag.is-on { border-color: rgba(186, 162, 255, 0.45); }
.tag.is-on, .tag:hover, .page-row.is-current a, .page-row.is-current a:hover { background: #342652; }
.tags__custom { width: 5.5rem; min-height: 2rem; padding: 0.15rem 0.55rem; border-radius: 10px; }
.tray__list { min-height: 2.2rem; margin: 0; padding: 0; list-style: none; }
.page-row a { display: flex; align-items: center; gap: 0.4rem; padding: 0.38rem 0.55rem; border-radius: 7px; color: inherit; text-decoration: none; }
.page-row__tags { flex: none; }
.page-row__title { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-row--ghost { opacity: 0.35; }
.page-row--lift { border-radius: 7px; background: var(--paper); box-shadow: 0 10px 22px -14px rgba(28, 36, 48, 0.7); }

.canvas { position: relative; flex: 1; height: 100%; }
.menu-btn, .scrim { display: none; }
.work {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}
.page__title {
  flex: none;
  width: 100%;
  min-width: 0;
  min-height: calc(var(--logo-height) + 0.5rem);
  margin: 0 0 1rem;
  padding: 1.15rem calc(var(--logo-width) + 3.5rem) 1rem 1.4rem;
  border: 0;
  border-bottom: 1px solid var(--glass-line);
  border-radius: 0;
  background: var(--glass);
  backdrop-filter: blur(16px);
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
}
.page__title:focus, .page__body:focus { outline: none; }
.page__title:focus-visible, .page__body:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.work__grid {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.work__write, .work__read {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 1.1rem 1.4rem 1.4rem;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(16px);
}
.work__read { border-left: 1px solid var(--glass-line); }
.work__caption { flex: none; }

/* Only these two content panes expose scrollbars. */
.page__body, .preview {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  font-family: var(--read);
}
.page__body { width: 100%; padding: 0; border: 0; resize: none; background: transparent; font-size: 1.02rem; line-height: 1.6; }
.preview { color: var(--ink); font-size: 1.08rem; line-height: 1.65; overflow-wrap: anywhere; }
.preview > :first-child { margin-top: 0; }
.preview h1, .preview h2, .preview h3 { margin: 1.2rem 0 0.45rem; font-family: var(--ui); letter-spacing: -0.03em; line-height: 1.25; }
.preview h1 { font-size: 1.55rem; }
.preview h2 { font-size: 1.28rem; }
.preview h3 { font-size: 1.08rem; }
.preview p { margin: 0.7rem 0; }
.preview a, .gate__switch a { color: var(--accent-deep); }
.preview ul, .preview ol { margin: 0.7rem 0; padding-left: 1.2rem; }
.preview blockquote { margin: 0.8rem 0; padding-left: 0.85rem; border-left: 3px solid #6d5aa8; color: #cbbfe0; }
.preview pre { overflow: visible; margin: 0.8rem 0; padding: 0.8rem 0.9rem; border-radius: 8px; background: var(--side); font-size: 0.9rem; line-height: 1.45; }
.preview pre, .preview code { font-family: ui-monospace, "Cascadia Code", monospace; }
.preview code { font-size: 0.92em; }
.preview img { max-width: 100%; height: auto; }
.preview hr { margin: 1.2rem 0; border: 0; border-top: 1px solid var(--line); }
.work--empty { align-items: center; justify-content: center; padding: 1.4rem; background: var(--glass); backdrop-filter: blur(16px); color: var(--muted); }
.work--empty p { margin: 0; }

.gate {
  display: flex;
  align-items: safe center;
  justify-content: center;
  height: 100dvh;
  min-width: 0;
  padding: 7rem 1.25rem 3rem;
  overflow: auto;
  scrollbar-width: none;
}
.gate__sheet {
  position: relative;
  z-index: 1;
  flex: 0 1 24rem;
  min-width: 0;
  padding: 1.7rem 1.45rem 1.25rem;
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  animation: settle 0.56s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.gate .field input { background: rgba(12, 9, 20, 0.42); border-color: rgba(186, 162, 255, 0.28); }
.gate__sheet h1 { margin: 0 0 1.2rem; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.03em; }
.gate__sheet h1::after { content: ""; display: block; width: 2.6rem; height: 2px; margin-top: 0.7rem; background: var(--accent); transform-origin: left center; animation: rule 0.7s 0.16s ease both; }
.gate .btn-ink, .gate .side-btn { width: 100%; }
.gate__switch { margin: 1rem 0 0; }
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 70; max-width: calc(100vw - 2rem); }
.note-toast { border: 1px solid var(--line); border-radius: 8px; background: #2a2140; color: var(--ink); }

@keyframes drift {
  from { transform: translate3d(-2.5%, -1.5%, 0) scale(1); }
  to { transform: translate3d(2.5%, 2%, 0) scale(1.08); }
}
@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes rule { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (max-width: 1100px) {
  .work__grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .work__read { border-left: 0; border-top: 1px solid var(--glass-line); }
}
@media (max-width: 860px) {
  :root { --logo-height: 3.5rem; --logo-width: 8rem; }
  .site-logo { right: 0.75rem; top: 0.25rem; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 65; width: min(20.5rem, 90vw); transform: translateX(-105%); box-shadow: 16px 0 30px -24px rgba(28, 36, 48, 0.7); }
  .side.is-open { transform: none; }
  .menu-btn { position: relative; z-index: 1; display: inline-flex; align-self: flex-start; flex: none; min-height: 3rem; margin: 0; padding: 0.6rem 1.4rem; border: 0; background: transparent; cursor: pointer; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 64; border: 0; background: rgba(28, 36, 48, 0.28); color: transparent; }
  .page__title { min-height: 3.5rem; margin-bottom: 0.5rem; padding: 0.6rem 1rem; font-size: 1.6rem; }
  .work__write, .work__read { padding: 0.6rem 1rem; }
  .gate { padding: 4.5rem 1rem 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .side, .gate__sheet, .gate__sheet h1::after, .glow, body::before, .pages-panel, .account-panel { animation: none; transition: none; }
}
