  :root {
    color-scheme: light;
    --ink: #163a33;
    --muted: #526760;
    --forest: #153e34;
    --leaf: #265c4b;
    --mint: #e4efe8;
    --paper: #f4f4ed;
    --white: #fffefa;
    --line: #dce3da;
    --accent: #e0edb6;
    --danger: #9c3a30;
    font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
  }
  *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body { margin: 0; }
  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; }
  button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
  :focus-visible { outline: 3px solid #508771; outline-offset: 3px; }
  h1, h2, h3, p { margin: 0; }
  h1, .serif { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
  .wrap { width: min(1120px, calc(100% - 56px)); margin-inline: auto; }
  .masthead { background: var(--forest); color: #fffefa; padding: 27px 0 68px; }
  .topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .brand { display: flex; align-items: center; gap: 11px; font-size: 1.08rem; font-weight: 650; }
  .brand-mark { display: grid; place-items: center; width: 37px; height: 37px; background: #ffd0b4; color: #47203f; border-radius: 11px; flex: 0 0 auto; }
  .brand-mark::before { content: "“"; font: bold 3.2rem/.7 Georgia, serif; transform: translateY(8px); }
  .brand-name { display: inline-flex; align-items: baseline; color: #ffe4d6; font-size: 1.43rem; letter-spacing: -.035em; font-weight: 750; }
  .brand-i { display: grid; place-items: center; width: .42em; height: .68em; margin: 0 .055em; border-block: .085em solid; }
  .brand-i::after { content: ""; height: 100%; width: .105em; background: currentColor; }
  .toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .phrase-note { margin-top: 10px; color: var(--muted); font-size: .85rem; }
  .reader h2:focus { outline: none; }
  .masthead { background: linear-gradient(112deg, #322638, #463047); }
  .intro { margin-top: 32px; }
  h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); line-height: 1.05; letter-spacing: -.055em; }
  .intro p { margin-top: 10px; color: #ecdadd; }
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; min-height: 42px; font-weight: 650; line-height: 1.25; }
  .btn-light { background: #ffd0b4; color: #47203f; }
  .btn-light:hover { background: #ffe3d3; }
  .btn-primary { background: var(--leaf); color: white; }
  .btn-primary:hover { background: var(--forest); }
  .btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
  .btn-secondary:hover { background: var(--mint); }
  .toolbar { position: relative; margin-top: -33px; padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 225px) auto; gap: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 5px 18px #163a330d; }
  .search { display: flex; align-items: center; gap: 12px; padding-left: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f9faf5; }
  .search-icon { flex: 0 0 14px; width: 14px; height: 14px; border: 2px solid var(--leaf); border-radius: 50%; position: relative; }
  .search-icon::after { content: ""; position: absolute; width: 6px; height: 2px; background: var(--leaf); transform: rotate(45deg); right: -5px; bottom: -2px; }
  .search input { width: 100%; min-width: 0; padding: 11px 10px 11px 0; background: transparent; border: 0; color: var(--ink); border-radius: 8px; }
  select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); color: var(--ink); padding: 7px 10px; }
  .workspace { margin-top: 24px; display: grid; grid-template-columns: minmax(255px, .85fr) minmax(0, 1.55fr); gap: 18px; align-items: start; }
  .panel { background: var(--white); border: 1px solid var(--line); border-radius: 17px; }
  .collection header { padding: 17px 19px 13px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .collection h2 { font-size: 1rem; }
  .count { color: var(--muted); font-size: .85rem; }
  .phrase-list { display: grid; gap: 5px; padding: 8px; max-height: 520px; overflow-y: auto; }
  .phrase { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; text-align: left; width: 100%; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); padding: 10px 11px; }
  .phrase:hover { background: #f2f6ef; }
  .phrase[aria-pressed=true] { background: var(--mint); border-color: #ccdcd2; }
  .phrase:focus-visible { outline-offset: -3px; }
  .phrase-title { font-weight: 650; overflow-wrap: anywhere; }
  .phrase-category { grid-row: 2; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
  .chevron { grid-column: 2; grid-row: 1 / 3; align-self: center; font-size: 1.25rem; color: var(--leaf); }
  .reader { padding: clamp(16px, 3vw, 30px); min-height: 315px; }
  .tags { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 13px; }
  .tag { border-radius: 100px; background: var(--mint); color: var(--forest); padding: 4px 10px; font-size: .8rem; font-weight: 650; overflow-wrap: anywhere; }
  .tag-example { background: #f0ede3; color: #675938; }
  .reader h2 { font-size: clamp(1.7rem, 3.5vw, 2.43rem); line-height: 1.14; letter-spacing: -.025em; overflow-wrap: anywhere; }
  .phrase-text { white-space: pre-wrap; overflow-wrap: anywhere; background: #f8f9f3; border: 1px solid var(--line); border-left: 3px solid #729783; border-radius: 8px; margin-top: 18px; padding: 16px; }
  .reader-actions { margin-top: 17px; display: flex; flex-wrap: wrap; gap: 8px; }
  .empty { color: var(--muted); padding: 10px; overflow-wrap: anywhere; }
  .reader .empty { padding: 16px 0; }
  .reader .empty p { margin-top: 10px; }
  .status-line { color: var(--muted); font-size: .86rem; margin: 13px 0 32px; min-height: 24px; }
  dialog { width: min(580px, calc(100% - 28px)); max-height: calc(100% - 28px); border: 1px solid var(--line); border-radius: 18px; background: var(--white); color: var(--ink); padding: clamp(16px, 4vw, 27px); box-shadow: 0 24px 75px #102b3d38; }
  dialog::backdrop { background: #132d29a3; }
  dialog h2 { font-size: 2rem; line-height: 1.1; margin-bottom: 14px; }
  .form-fields { display: grid; gap: 11px; }
  .field { display: grid; gap: 4px; font-size: .9rem; font-weight: 650; }
  .field input, .field textarea { width: 100%; border: 1px solid #cdd8ce; border-radius: 8px; background: white; padding: 9px 11px; color: var(--ink); font-size: 1rem; font-weight: 400; }
  .field textarea { resize: vertical; min-height: 112px; }
  .form-note { color: var(--muted); font-size: .82rem; }
  .form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  .form-actions .btn-primary { margin-left: auto; }
  .btn-danger { background: transparent; color: var(--danger); }
  .btn-danger:hover { background: #f8edea; }
  .toast { position: fixed; z-index: 1; right: 20px; bottom: 20px; color: white; background: var(--forest); border-radius: 12px; padding: 11px 16px; box-shadow: 0 4px 25px #163a3329; max-width: calc(100vw - 40px); }
  .sr-only { display: block; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  @media (max-width: 700px) {
    .wrap { width: calc(100% - 28px); }
    .masthead { padding-top: 17px; }
    .intro { margin-top: 24px; }
    .topline { gap: 7px; }
    .topline .btn { font-size: .82rem; padding: 8px 10px; }
    .toolbar { grid-template-columns: minmax(0, 1fr); }
    .toolbar-actions > button { flex: 1 1 120px; }
    .workspace { margin-top: 16px; grid-template-columns: 1fr; gap: 12px; }
    .phrase-list { max-height: 195px; }
    .reader { min-height: 0; }
  }
  .fill-input, .inline-field select { border: 1px solid #648474; border-radius: 6px; color: var(--ink); background: var(--white); font: inherit; margin: 2px 0; min-height: 32px; padding: 2px 6px; vertical-align: baseline; }
  .fill-input { width: 9.5ch; max-width: 100%; }
  .fill-input:focus { width: 22ch; }
  .fill-input.fill-number { width: 7ch; }
  .fill-input[aria-invalid=true] { border-color: var(--danger); }
  .inline-field { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; vertical-align: baseline; max-width: 100%; }
  .inline-field select, .inline-field .fill-custom { width: 7ch; min-width: 0; padding-inline: 4px; }
  .inline-field select { text-overflow: ellipsis; }
  .inline-field .fill-custom.has-answer { width: min(22ch, 60vw); }
  @supports (appearance: base-select) {
    .inline-field select, .inline-field select::picker(select) { appearance: base-select; }
    .inline-field select { gap: 2px; }
    .inline-field select selectedcontent { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .inline-field select::picker-icon { flex-shrink: 0; font-size: .7em; }
    .inline-field select::picker(select) {
      width: max-content;
      min-width: anchor-size(width);
      max-width: calc(100vw - 24px);
      border: 1px solid #648474;
      border-radius: 6px;
      background: var(--white);
    }
    .inline-field select option { padding: 5px 9px; white-space: normal; overflow-wrap: anywhere; }
  }
  .answer-add, .field-tool { color: var(--forest); background: var(--mint); border: 1px solid #648474; border-radius: 6px; padding: 2px 7px; min-width: 30px; min-height: 30px; font-weight: 700; }
  .answer-add:hover, .field-tool:hover { background: #d3e6d8; }
  .field-tools { display: flex; flex-wrap: wrap; gap: 6px; }
  .field-tool { display: grid; place-items: center; width: 42px; height: 42px; }
  .field-tool svg { width: 21px; height: 21px; }
  .body-editor { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 128px; max-height: 35vh; overflow-y: auto; border: 1px solid #648474; border-radius: 8px; padding: 9px 11px; background: white; }
  .editor-chip { display: inline-block; border: 1px solid #648474; border-radius: 5px; padding: 0 7px; margin: 2px 0; background: var(--mint); color: var(--forest); font-size: .82em; font-weight: 650; user-select: all; }

.auth-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.auth-screen { margin-block: 28px 44px; }
.auth-panel { width: min(100%, 430px); margin-inline: auto; padding: 25px; }
.auth-panel h2 { font-size: 1.85rem; }
.auth-panel form, .auth-panel > button { margin-top: 16px; }
.auth-status:not(:empty) { margin-top: 8px; color: var(--muted); }
.save-error { color: var(--danger); margin-top: 12px; }
