:root {
  color-scheme: light;
  --page: #f3f6f4;
  --paper: #ffffff;
  --ink: #1d3029;
  --muted: #52675d;
  --green: #1b5b45;
  --mint: #e4f1ea;
  --line: #d9e3dd;
  --rust: #982f26;
  --radius: 15px;
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); line-height: 1.55; }
a { color: var(--green); text-underline-offset: .24em; }
button, input, select, textarea { font: inherit; }
button, .button {
  display: inline-block; padding: .56rem .92rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-decoration: none; line-height: 1.5;
}
button:hover, .button:hover { background: var(--mint); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
button:disabled, input:disabled { opacity: .65; cursor: default; }
button.primary, .button.primary { color: white; background: var(--green); border-color: var(--green); }
button.primary:hover, .button.primary:hover { background: #154833; }
button.plain { border-color: transparent; background: transparent; color: var(--green); }
button.plain:hover { background: var(--mint); }
button.danger { color: var(--rust); }
input:not([type=checkbox]), textarea, select {
  display: block; width: 100%; border: 1px solid var(--line); border-radius: 8px;
  background: #fcfefd; color: var(--ink); padding: .62rem .75rem;
}
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--green); }
textarea { resize: vertical; }
select { appearance: none; padding-right: 2.4rem; background-image: linear-gradient(45deg, transparent 49%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 51%); background-position: calc(100% - 1.05rem) 50%, calc(100% - .75rem) 50%; background-size: .3rem .31rem; background-repeat: no-repeat; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 2.7rem); font-weight: 660; line-height: 1.2; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; line-height: 1.3; }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); }
summary { cursor: pointer; color: var(--green); }
.meta { font-size: .875rem; color: var(--muted); }
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1280px; margin: auto; display: flex; align-items: center; gap: 2.15rem; min-height: 68px; padding: .55rem clamp(1rem, 5vw, 3.6rem); }
.brand { display: inline-flex; align-items: center; gap: .58rem; font-size: 1.25rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-mark { background: var(--green); border-radius: 8px; color: white; width: 2rem; height: 2rem; display: grid; place-items: center; font: 700 1.35rem Georgia, serif; }
.header-inner nav, .account-nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.header-inner nav a, .account-nav a { text-decoration: none; padding: .45rem .67rem; color: var(--muted); border-radius: 6px; }
a[aria-current=page] { color: var(--green) !important; background: var(--mint); font-weight: 650; }
.logout { margin-left: auto; }
.container { width: min(100%, 1280px); margin-inline: auto; padding: clamp(1.1rem, 4vw, 3.2rem) clamp(1rem, 5vw, 3.6rem) 5rem; }
.narrow { max-width: 820px; }
.page-heading, .panel-heading { display: flex; justify-content: space-between; gap: .75rem; align-items: center; }
.page-heading { margin-bottom: 1.4rem; }
.panel { padding: clamp(1rem, 3vw, 1.65rem); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.stack { display: grid; gap: 1rem; align-items: start; }
.stack label:not(.check) { display: grid; gap: .3rem; }
.stack button { justify-self: start; }
.notice { margin: 0 0 1rem; padding: .65rem .85rem; border: 1px solid var(--line); background: var(--mint); border-radius: 8px; }
.notice.error { color: var(--rust); background: #fff0ed; border-color: #efc9c0; }

.library-layout { display: grid; grid-template-columns: minmax(165px, 220px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.sidebar { display: grid; gap: 1.4rem; }
.section-links { display: grid; gap: .25rem; }
.section-links a { text-decoration: none; padding: .5rem .65rem; border-radius: 8px; overflow-wrap: anywhere; }
.section-links a:hover { background: var(--mint); }
.section-links h2 { font-size: .875rem; color: var(--muted); padding-inline: .65rem; }
.category-form { display: flex; padding-top: .5rem; gap: .2rem; }
.category-form input { min-width: 0; font-size: .92rem; }
.category-form button { flex: 0 0 auto; padding-inline: .45rem; }
.article-list { padding-block: 0; }
.article-row { display: grid; gap: .22rem; padding-block: 1.1rem; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.article-row + .article-row { border-top: 1px solid var(--line); }
.article-row strong { font-size: 1.13rem; }
.article-row:hover strong { text-decoration: underline; text-decoration-color: var(--green); text-underline-offset: .23em; }
.statuses { color: var(--green); font-size: .875rem; }
.empty { padding-block: clamp(2rem, 8vw, 4rem); text-align: center; }
.empty p { color: var(--muted); margin-top: .5rem; }
.compose textarea { font: 1.16rem/1.65 "Segoe UI", Arial, Roboto, sans-serif; }

.reader-heading { margin-bottom: 1.5rem; }
.reader-heading h1 { margin-top: .5rem; }
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 310px); gap: 1.25rem; align-items: start; }
.reading-column, .reader-aside { display: grid; gap: 1rem; min-width: 0; }
.reading-tools { display: grid; gap: .75rem; }
.toolbar, .check, .speed { display: flex; align-items: center; gap: .55rem; }
.toolbar { justify-content: space-between; }
.speed { flex-shrink: 0; }
.speed select { width: auto; padding-block: .35rem; }
.reading-tools audio { display: block; width: 100%; }
.job-statuses { display: grid; gap: .22rem; font-size: .875rem; color: var(--muted); }
.job-error { color: var(--rust); }
.job form { display: inline; }
.job button { padding: .18rem .4rem; }
.reading { padding: clamp(1.1rem, 4vw, 2.4rem); }
.paragraph + .paragraph { margin-top: 1.25rem; }
.russian { font: clamp(1.12rem, 2.4vw, 1.39rem)/1.78 "Segoe UI", Arial, Roboto, sans-serif; overflow-wrap: anywhere; white-space: pre-wrap; }
.word { display: inline; padding: 0; border: 0; color: inherit; background: none; border-radius: 3px; font: inherit; overflow-wrap: anywhere; }
.word:hover, .word:focus-visible { color: var(--green); background: var(--mint); text-decoration: underline; text-underline-offset: .23em; }
.translation { color: var(--muted); border-left: .18rem solid #b6d9c6; margin-top: .6rem; padding: .15rem .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-panel textarea { margin-top: .75rem; min-height: 150px; }
.note-panel h2 label { cursor: text; }
.manage-panel form, .user-actions details form { padding-top: .8rem; }
.word-dialog { width: min(570px, calc(100% - 2rem)); max-height: min(76vh, 740px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--paper); box-shadow: 0 16px 60px #143a2a38; }
.word-dialog::backdrop { background: #12292080; }
.dialog-header { position: sticky; top: 0; z-index: 1; padding: .8rem 1.2rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; background: var(--paper); border-bottom: 1px solid var(--line); }
.dialog-header h2 { font: 700 1.65rem "Segoe UI", Arial, Roboto, sans-serif; overflow-wrap: anywhere; }
#word-results { padding: 1.2rem; }
.word-entry { display: grid; gap: .65rem; }
.word-entry + .word-entry { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.lemma-title { font: 700 1.4rem Georgia, serif; overflow-wrap: anywhere; }
.analysis-list { margin: 0; padding-left: 1.25rem; }
.forms { border-collapse: collapse; width: 100%; font-size: .9rem; margin-top: .45rem; }
.forms td, .forms th { text-align: left; padding: .32rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.forms td:first-child { font: 1.05rem Georgia, serif; }
.word-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.word-actions button { font-size: .9rem; }
.word-message { color: var(--muted); }

.vocabulary-row { display: flex; align-items: start; justify-content: space-between; gap: .8rem; padding: 1rem 0; }
.vocabulary-row + .vocabulary-row, .user-row { border-top: 1px solid var(--line); }
.vocabulary-row h2 { font: 700 1.4rem Georgia, serif; }
.vocabulary-row p:not(.meta) { margin-top: .35rem; }
.vocabulary-row blockquote { margin: .5rem 0; padding-left: .8rem; color: var(--muted); border-left: .18rem solid var(--line); overflow-wrap: anywhere; }
.account-nav { margin-bottom: .85rem; }
.users { margin-top: 1rem; }
.user-row { padding-top: .7rem; margin-top: .7rem; }
.user-actions { display: grid; gap: .45rem; margin-top: .65rem; }
.login-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.25rem; align-items: stretch; max-width: 970px; padding-top: clamp(2rem, 9vh, 6rem); }
.login-layout .notice { grid-column: 1 / -1; margin-bottom: 0; }
.login-brand { position: relative; padding: clamp(1.4rem, 5vw, 3rem); min-height: 310px; display: grid; align-content: end; border-radius: var(--radius); overflow: hidden; background: #133f31; color: #e7f5ed; }
.login-glyph { color: #87bd9e34; position: absolute; right: 5%; top: -26%; font: 700 clamp(13rem, 42vw, 24rem) Georgia, serif; pointer-events: none; }
.login-brand p { font: 1.6rem Georgia, serif; color: #b9e2ca; margin-bottom: .7rem; }
.login-panel { display: grid; align-content: center; gap: 1.3rem; }
.login-panel h2 { font-size: 1.5rem; }
.login-panel button { width: 100%; }

@media (max-width: 780px) {
  .reader-layout { grid-template-columns: 1fr; }
  .reader-aside { grid-template-columns: 1fr; }
}
@media (max-width: 575px) {
  .header-inner { gap: .42rem; }
  .brand { font-size: 1rem; gap: .35rem; }
  .brand-mark { width: 1.6rem; height: 1.6rem; font-size: 1rem; }
  .header-inner nav { gap: .1rem; }
  .header-inner nav a { padding: .35rem .36rem; font-size: .875rem; }
  .logout button { padding: .3rem .25rem; font-size: .875rem; }
  .login-layout, .library-layout { grid-template-columns: 1fr; }
  .login-brand { min-height: 170px; }
  .sidebar { gap: .5rem; }
  .section-links { display: flex; flex-wrap: wrap; align-items: center; }
  .category-form { padding-top: 0; }
  .page-heading .button { flex-shrink: 0; }
}
