:root {
    --paper: #F4F8FC; --paper-dim: #E7F0F9; --ink: #2A3440; --ink-soft: #5C6B7A;
    --line: #D6E3EE; --thread: #4A80C2; --thread-dark: #38669E;
    --brass: #DA8A4F; --brass-soft: #FCE8D5; --card: #FFFFFF; --danger: #CC5F5F;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; background: var(--paper); color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }
  h1, h2, h3, .serif { font-family: Georgia, "Times New Roman", serif; }
  .mono { font-family: "SF Mono", Menlo, Consolas, monospace; }

  header {
    background: var(--paper-dim); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 500;
  }
  .header-inner { max-width: 960px; margin: 0 auto; padding: 14px 16px 0; }
  .header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .header-row h1 { font-size: 20px; margin: 0; font-weight: 600; }
  .icon-btn { background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px; }

  nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
  nav.tabs button {
    display: flex; align-items: center; gap: 5px; padding: 8px 11px;
    border: none; cursor: pointer; background: transparent; color: var(--ink-soft);
    font-weight: 600; font-size: 13.5px; border-radius: 10px 10px 0 0;
    border-bottom: 2px solid transparent; white-space: nowrap; font-family: inherit;
  }
  nav.tabs button.active { background: var(--paper); color: var(--thread); border-bottom-color: var(--thread); }

  nav.bottom-tabs {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--paper-dim); border-top: 1px solid var(--line);
    justify-content: space-around; padding: 5px 2px calc(5px + env(safe-area-inset-bottom)); z-index: 600;
    overflow-x: auto;
  }
  nav.bottom-tabs button {
    background: none; border: none; cursor: pointer; flex: 1 0 52px;
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    color: var(--ink-soft); font-family: inherit; padding: 3px 1px;
  }
  nav.bottom-tabs button.active { color: var(--thread); }
  nav.bottom-tabs .glyph { font-size: 17px; }
  nav.bottom-tabs .lbl { font-size: 9.5px; font-weight: 600; }

  /* --- App-Shell: Seitenleiste (Desktop) / Topbar + Burger (Mobil) --- */
  .app { display: flex; min-height: 100vh; }
  .sidebar {
    width: 210px; flex: 0 0 210px; background: var(--paper-dim);
    border-right: 1px solid var(--line); position: sticky; top: 0;
    height: 100vh; overflow-y: auto; padding: 18px 12px 14px;
    display: flex; flex-direction: column; gap: 2px;
  }
  .brand { font-family: Georgia, serif; font-weight: 600; font-size: 18px; padding: 0 8px 14px; }
  .nav-label {
    font-family: "SF Mono", Menlo, monospace; font-size: 10px; letter-spacing: 1px;
    text-transform: uppercase; color: #8AA3BC; margin: 14px 8px 5px;
  }
  .navbtn {
    display: flex; width: 100%; align-items: center; gap: 11px; padding: 10px 10px;
    border: none; background: transparent; color: var(--ink-soft); border-radius: 10px;
    cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; text-align: left;
  }
  .navbtn:hover { background: rgba(255,255,255,0.55); }
  .navbtn.active { background: var(--paper); color: var(--thread); box-shadow: inset 0 0 0 1px var(--line); }
  .nglyph { font-size: 17px; width: 22px; text-align: center; }
  .content { flex: 1; min-width: 0; }
  .topbar {
    display: none; position: sticky; top: 0; z-index: 500;
    background: var(--paper-dim); border-bottom: 1px solid var(--line);
    padding: 12px 16px; justify-content: space-between; align-items: center;
  }
  .topbar h1 { font-size: 19px; margin: 0; font-weight: 600; }
  .burger { font-size: 21px; }
  @media (max-width: 720px) {
    .sidebar { display: none; }
    .topbar { display: flex; }
  }
  [hidden] { display: none !important; }
  .menu-backdrop { position: fixed; inset: 0; background: rgba(42,52,64,0.45); z-index: 890; }
  .mobile-menu {
    position: fixed; top: 0; right: 0; bottom: 0; width: 78%; max-width: 320px;
    background: var(--paper-dim); border-left: 1px solid var(--line); z-index: 900;
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); overflow-y: auto;
    box-shadow: -8px 0 24px rgba(0,0,0,0.18);
  }
  .mobile-menu-head {
    display: flex; justify-content: space-between; align-items: center;
    font-family: Georgia, serif; font-weight: 600; font-size: 18px; margin-bottom: 10px; padding: 0 6px;
  }
  .mobile-menu button.mi {
    display: flex; width: 100%; align-items: center; gap: 12px; padding: 13px 12px;
    border: none; background: transparent; color: var(--ink-soft); border-radius: 10px;
    cursor: pointer; font-family: inherit; font-size: 15px; font-weight: 600; text-align: left;
  }
  .mobile-menu button.mi.active { background: var(--paper); color: var(--thread); }
  #backupBar {
    background: #FDF3E3; border-top: 1px solid var(--brass);
    padding: 8px 16px; font-size: 13px; color: #8A5A2E;
    display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  }

  main { max-width: 960px; margin: 0 auto; padding: 22px 16px 80px; }
  .section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
  .section-head h2 { font-size: 21px; margin: 0 0 4px; }
  .section-head p { color: var(--ink-soft); margin: 0; font-size: 13.5px; max-width: 460px; }

  .empty {
    text-align: center; padding: 42px 18px; color: var(--ink-soft);
    border: 1px dashed var(--line); border-radius: 14px; background: rgba(255,255,255,0.5);
    font-size: 14px;
  }
  .empty .glyph { font-size: 26px; display: block; margin-bottom: 8px; opacity: 0.75; }

  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
  .card.clickable { cursor: pointer; transition: box-shadow .15s ease; }
  .card.clickable:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
  .card h3 { font-size: 16.5px; margin: 0 0 2px; font-weight: 600; }
  .card .meta { font-size: 12px; color: var(--brass); margin-bottom: 6px; }
  .card .sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
  .card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

  .btn {
    display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
    border-radius: 8px; border: 1px solid transparent; cursor: pointer;
    font-size: 14px; padding: 9px 15px; font-family: inherit;
    background: var(--thread); color: #fff;
  }
  .btn.sm { font-size: 13px; padding: 6px 10px; }
  .btn.secondary { background: transparent; color: var(--thread); border-color: var(--thread); }
  .btn.ghost { background: transparent; color: var(--ink-soft); }
  .btn.danger { background: transparent; color: var(--danger); border-color: rgba(204,95,95,0.4); }
  .btn.brass { background: var(--brass); color: #fff; }
  .btn:disabled { opacity: 0.55; cursor: default; }

  label.field { display: block; margin-bottom: 13px; }
  label.field > span, .field-label {
    display: block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--ink-soft); margin-bottom: 5px; font-weight: 600;
  }
  input, textarea, select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: 15px; color: var(--ink); background: #fff;
  }
  input:focus, textarea:focus, select:focus { outline: 2px solid var(--thread); outline-offset: 1px; }
  textarea { resize: vertical; }
  .form-row { display: flex; gap: 12px; }
  .form-row > * { flex: 1; }
  .field-hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }

  .modal-overlay {
    position: fixed; inset: 0; background: rgba(42,52,64,0.45); z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 4vh 14px; overflow-y: auto;
  }
  .modal {
    background: var(--paper); border-radius: 16px; width: 100%; max-width: 500px;
    padding: 22px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  }
  .modal.wide { max-width: 660px; }
  .modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
  .modal-head h3 { font-size: 20px; margin: 0; }
  .modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

  /* fact cards */
  .fact-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; position: relative;
  }
  .fact-date {
    display: inline-block; font-size: 12px; font-weight: 600; color: #fff;
    background: var(--thread); border-radius: 6px; padding: 3px 9px; margin-bottom: 7px;
  }
  .fact-date.undated { background: var(--ink-soft); }
  .fact-text { font-size: 14px; line-height: 1.55; margin: 0; white-space: pre-wrap; }
  .fact-place { font-size: 12px; color: var(--brass); margin-top: 6px; }
  .fact-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; }
  .fact-actions button { background: none; border: none; cursor: pointer; font-size: 13px; padding: 3px; opacity: 0.65; }
  .fact-actions button:hover { opacity: 1; }
  .fact-card.hl { border-color: var(--brass); border-width: 2px; background: #FFFBF3; }
  .fact-epoch-head {
    display: flex; align-items: baseline; gap: 10px; margin: 20px 0 10px;
    font-family: Georgia, serif; font-size: 15.5px; font-weight: 600; color: var(--ink);
    border-bottom: 1px solid var(--line); padding-bottom: 5px;
  }
  .fact-star { color: #D98A2B; }

  .detail-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 14px; flex-wrap: wrap; margin-bottom: 6px;
  }
  .detail-head h2 { margin: 0 0 2px; font-size: 24px; }
  .back-link {
    background: none; border: none; color: var(--thread); cursor: pointer;
    font-size: 13.5px; font-weight: 600; padding: 0; margin-bottom: 14px; font-family: inherit;
  }
  .detail-meta { font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; margin-bottom: 4px; }
  .detail-meta b { color: var(--ink); font-weight: 600; }

  .timeline { position: relative; padding-left: 26px; }
  .timeline::before {
    content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
    width: 2px; background: var(--line); border-radius: 2px;
  }
  .epoch { position: relative; margin-bottom: 16px; }
  .epoch::before {
    content: ""; position: absolute; left: -26px; top: 20px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--thread); border: 3px solid var(--paper);
    box-shadow: 0 0 0 2px var(--thread);
  }
  .epoch-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
  .epoch-summary { display: flex; justify-content: space-between; align-items: center; padding: 15px 16px; cursor: pointer; }
  .epoch-years { font-size: 12px; color: var(--brass); margin-bottom: 2px; }
  .epoch-title { font-size: 18px; font-family: Georgia, serif; }
  .epoch-body { padding: 0 16px 18px; border-top: 1px solid var(--line); }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
  .chip { font-size: 12.5px; padding: 4px 10px; border-radius: 20px; background: var(--brass-soft); color: #8A5A2E; }
  .chip.toggle { cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); }
  .chip.toggle.on { background: var(--thread); border-color: var(--thread); color: #fff; }
  .sub-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
  .sub-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 8px; gap: 8px; flex-wrap: wrap; }
  .events-list { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; }
  .events-list b { color: var(--ink); font-weight: 600; }
  .narrative { font-family: Georgia, serif; font-size: 15.5px; line-height: 1.75; white-space: pre-wrap; margin: 0; }
  .hint { font-size: 13px; color: var(--ink-soft); font-style: italic; margin: 0; }
  .error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }

  .rel-form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 18px; }
  .rel-form .form-row { flex-wrap: wrap; align-items: flex-end; }
  .rel-form .form-row > * { min-width: 160px; }
  .rel-item {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 11px 14px; background: var(--card); border: 1px solid var(--line);
    border-radius: 10px; margin-bottom: 8px; font-size: 14px;
  }

  .tree-wrap {
    overflow: auto; background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; padding: 10px; height: 62vh; cursor: grab;
    touch-action: pan-x pan-y; overscroll-behavior: contain;
  }
  @media (max-width: 720px) { .tree-wrap { height: 60vh; } }
  .tree-node rect { transition: stroke-width .12s ease; }
  .tree-node:hover rect { stroke-width: 3; }
  .legend { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }

  /* map */
  .map-toggles {
    display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
  }
  .map-toggles label { display: flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
  .map-toggles input { width: auto; }
  #mapDiv { height: 480px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper-dim); }
  @media (max-width: 720px) { #mapDiv { height: 62vh; } }
  .map-msg { padding: 40px 20px; text-align: center; color: var(--ink-soft); font-size: 14px; }
  .leaflet-container { font-family: inherit; }

  /* Gesamtübersicht */
  .sum-title { margin-bottom: 18px; }
  .sum-meta { font-size: 12px; color: var(--ink-soft); }
  .sum-section { margin-bottom: 26px; }
  .sum-section h3 {
    font-size: 17px; border-bottom: 2px solid var(--thread);
    padding-bottom: 4px; margin: 0 0 12px;
  }
  .sum-block {
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 10px;
  }
  .sum-block h4 { margin: 0 0 5px; font-size: 15px; }
  .sum-line { font-size: 13px; color: var(--ink-soft); margin: 2px 0; line-height: 1.55; }
  .sum-line b { color: var(--ink); }
  ul.sum-facts { margin: 4px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.65; color: var(--ink-soft); }
  ul.sum-facts b { color: var(--ink); }

  .teil-block { margin-bottom: 34px; }
  .teil-intro { border-left: 3px solid var(--brass); padding: 10px 0 6px 14px; margin: 0 0 14px; }
  .lese-teil-intro {
    font-family: Georgia, serif; font-style: italic; line-height: 1.75;
    max-width: 520px; margin: 16px auto 0; text-align: left; color: var(--ink);
  }

  /* Teil-Überschriften */
  .teil-head {
    display: flex; align-items: baseline; gap: 12px;
    font-family: Georgia, serif; font-size: 19px; font-weight: 600;
    margin: 30px 0 12px; padding-bottom: 8px;
    border-bottom: 2px solid var(--brass);
  }
  .teil-head .mono { font-size: 11px; letter-spacing: 2px; color: var(--brass); text-transform: uppercase; }
  .lese-teil { text-align: center; margin: 60px 0 44px; }
  .lese-teil h2 {
    font-family: Georgia, serif; font-size: 27px; font-weight: 600;
    margin: 6px 0 0; padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }
  .lese-teil .lese-kapnr { margin-bottom: 2px; }

  /* Login-Schleier */
  .auth-overlay {
    position: fixed; inset: 0; z-index: 300; background: var(--paper);
    display: flex; align-items: center; justify-content: center; padding: 20px;
  }
  .auth-card {
    width: 100%; max-width: 380px; background: var(--card);
    border: 1px solid var(--line); border-radius: 16px;
    padding: 30px 26px; text-align: center;
    box-shadow: 0 10px 40px rgba(42, 52, 64, 0.12);
  }
  .auth-card .field { text-align: left; }

  /* Startseite */
  .home-hero { text-align: center; margin: 26px 0 30px; }
  .home-hero h1 { font-size: 34px; margin: 8px 0 8px; font-weight: 600; }
  .home-hero p { color: var(--ink-soft); font-size: 15px; }
  .home-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px; max-width: 780px; margin: 0 auto;
  }
  .home-tile {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 18px 14px 16px; text-align: center; cursor: pointer;
    display: flex; flex-direction: column; gap: 5px; transition: transform 0.12s, box-shadow 0.12s;
  }
  .home-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(42,52,64,0.10); }
  .home-glyph { font-size: 30px; }
  .home-title { font-family: Georgia, serif; font-weight: 600; font-size: 15.5px; }
  .home-sub { font-size: 12px; color: var(--ink-soft); }

  /* Fertig-Markierung */
  .card { position: relative; }
  .done-toggle {
    position: absolute; top: 10px; right: 10px; width: 27px; height: 27px;
    border-radius: 50%; border: 1.5px solid var(--line); background: #fff;
    color: var(--ink-soft); cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center; z-index: 2;
  }
  .done-toggle.on { background: #7CA982; border-color: #7CA982; color: #fff; }
  .card.done { border-color: #9CC4A3; background: #F4FAF5; }
  .done-badge {
    display: inline-block; font-size: 11px; font-weight: 700; color: #4C7A55;
    background: #E2F0E4; border-radius: 12px; padding: 2px 9px; margin-left: 8px;
    vertical-align: middle; font-family: Inter, -apple-system, sans-serif;
  }
  .filter-row {
    display: flex; align-items: center; gap: 8px; font-size: 13.5px;
    color: var(--ink-soft); margin: 0 0 12px; cursor: pointer;
  }
  .filter-row input { width: auto; }
  .done-toggle.on-f { background: var(--brass); border-color: var(--brass); color: #fff; }
  .hp-badge {
    display: inline-block; font-size: 11px; font-weight: 700; color: #A9672F;
    background: #FCE8D5; border-radius: 12px; padding: 2px 9px; margin-left: 8px;
    vertical-align: middle; font-family: Inter, -apple-system, sans-serif;
  }
  .anhang { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 28px; }
  .register { max-width: 560px; }
  .register-entry {
    font-family: "American Typewriter", "Courier New", Courier, monospace;
    padding: 11px 2px; border-bottom: 1px dotted #B8C9DA;
    page-break-inside: avoid; line-height: 1.55;
  }
  .register-entry:last-child { border-bottom: none; }
  .reg-name { font-weight: 400; font-size: 14px; }
  .reg-geb { font-weight: 400; color: var(--ink-soft); }
  .reg-line { font-size: 12.5px; margin-top: 2px; }
  .reg-soft { color: var(--ink-soft); }
  .reg-dates { color: #CC5F5F; }
  .reg-sep { margin: 0 8px; color: #B8C9DA; }
  .anhang-map { height: 380px; border: 1px solid var(--line); border-radius: 12px; }
  .leaflet-tooltip.anhang-tip {
    background: transparent !important; border: none !important;
    box-shadow: none !important; padding: 0 !important; margin: 0;
    color: var(--ink); font-family: "American Typewriter", "Courier New", monospace;
    font-size: 11.5px; font-weight: 600;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 4px #fff, 1px 1px 2px #fff;
  }
  .leaflet-tooltip.anhang-tip::before { display: none !important; }
  .register-wrap { overflow-x: auto; }
  table.register { width: 100%; border-collapse: collapse; font-size: 12.5px; }
  table.register th, table.register td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
  table.register td:nth-child(7) { white-space: normal; }
  table.register th {
    font-family: "SF Mono", Menlo, monospace; font-size: 10px; letter-spacing: 0.8px;
    text-transform: uppercase; color: var(--ink-soft); border-bottom: 2px solid var(--line);
  }

  /* Ein-/ausklappbare Kartentexte */
  .desc { margin-top: 8px; margin-bottom: 4px; }
  .clamp {
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .more-btn {
    background: none; border: none; color: var(--thread); font-weight: 600;
    font-size: 12.5px; cursor: pointer; padding: 2px 0 6px; font-family: inherit;
  }

  /* Lesesaal */
  .reader { max-width: 680px; margin: 0 auto; }
  .lese-titel { text-align: center; margin: 26px 0 44px; }
  .lese-titel h1 { font-size: 32px; margin: 6px 0 10px; font-weight: 600; }
  .lese-meta { font-size: 12px; color: var(--ink-soft); }
  .lese-schmuck { text-align: center; font-size: 22px; color: var(--brass); }
  .lese-kapitel { margin-bottom: 44px; }
  .lese-kapnr { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--brass); margin-bottom: 4px; }
  .lese-kapitel h2 { font-size: 23px; margin: 0 0 14px; font-weight: 600; }
  .lese-text {
    font-family: Georgia, "Times New Roman", serif; line-height: 1.85;
    white-space: pre-wrap; margin: 0; color: var(--ink); text-align: justify; hyphens: auto;
  }
  .lese-kapitel .lese-text::first-letter {
    font-size: 3.55em; float: left; line-height: 0.8;
    padding: 7px 10px 0 0; margin-bottom: -6px;
    color: var(--thread); font-weight: 600;
  }
  @media print {
    .lese-text { text-align: left; }
    .lese-kapitel { page-break-inside: auto; }
    .lese-kapitel h2 { page-break-after: avoid; }
  }

  .ki-score {
    display: inline-block; font-size: 12px; font-weight: 600;
    border-radius: 14px; padding: 3px 11px; margin-top: 10px; cursor: pointer;
    font-family: Inter, -apple-system, sans-serif;
  }
  .ki-detail {
    border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
    padding: 10px 12px; margin-top: 8px; font-size: 12.5px; line-height: 1.55;
  }
  .ki-detail-line { margin-bottom: 4px; }

  /* Kapitel-Dialog */
  .chat-panel { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 12px; margin-top: 12px; }
  .chat-msgs { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
  .chat-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
  .chat-msg.user { align-self: flex-end; background: var(--thread); color: #fff; border-bottom-right-radius: 4px; }
  .chat-msg.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
  .chat-proposal { align-self: stretch; background: #EDF4FB; border: 1px solid var(--thread); border-radius: 10px; padding: 10px 12px; }
  .chat-proposal .narrative { font-size: 13.5px; max-height: 200px; overflow-y: auto; margin: 0; }
  .chat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
  .chip-btn { font-size: 12px; padding: 5px 10px; border-radius: 16px; border: 1px solid var(--thread); background: #fff; color: var(--thread); cursor: pointer; font-family: inherit; font-weight: 600; }
  .chip-btn:disabled { opacity: 0.5; cursor: default; }
  .chip-btn.style { border-color: var(--brass); color: #A9672F; }
  .chip-btn.style.on { background: var(--brass); color: #fff; }
  .chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
  .chat-input-row textarea { flex: 1; min-height: 44px; }

  @media print {
    header, .sidebar, .topbar, nav.bottom-tabs, .no-print, #modalRoot, #backupBar { display: none !important; }
    body { background: #fff; }
    main { max-width: 100%; padding: 0; }
    .sum-block { page-break-inside: avoid; break-inside: avoid; border-color: #bbb; }
    .sum-section h3 { page-break-after: avoid; }
  }

  .spin { display: inline-block; animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

  .banner {
    background: var(--brass-soft); border: 1px solid var(--brass); border-radius: 10px;
    padding: 10px 14px; font-size: 13px; margin-bottom: 18px; color: #8A5A2E;
  }
  .coord-badge { font-size: 12px; color: var(--ink-soft); }
