@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700&family=Figtree:wght@400;500;600&display=swap');

:root {
  --ink: #1E2621;
  --field: #D7DCD5;
  --bubble: #FBFAF7;
  --mine: #33403A;
  --cream: #F1EFE9;
  --muted: #7C8177;
  --rose: #EDA096;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  font-family: 'Figtree', system-ui, sans-serif;
  background: var(--ink);
  color: #22271F;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--field);
}

/* ------------------------------------------------------------- title bar */

#titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: max(10px, env(safe-area-inset-top)) 14px 12px;
  color: var(--cream);
  flex-shrink: 0;
  transition: background .2s;
}
.bar-title { font-family: 'Archivo'; font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.bar-sub { font-size: 12px; opacity: .62; margin-top: 1px; }
.back {
  border: 0; background: none; color: var(--cream);
  font-size: 30px; line-height: 1; padding: 0 10px 4px 0; cursor: pointer;
}

.screen { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen.chat { display: flex; flex-direction: column; overflow: hidden; }

/* ------------------------------------------------------------------ home */

.home { padding: 22px 18px 40px; }
.faces { display: flex; margin-bottom: 26px; }
.face {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: 'Archivo'; font-weight: 700; font-size: 14px; color: #fff;
  border: 2px solid var(--field); margin-left: -9px;
}
.face:first-child { margin-left: 0; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 20px 6px; padding-top: 4px;
}
.tile {
  border: 0; background: none; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.tile-icon {
  width: 58px; height: 58px; border-radius: 16px;
  background: var(--tint); display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.16);
  transition: transform .12s;
}
.tile-icon svg { width: 27px; height: 27px; color: var(--cream); }
.tile:active .tile-icon { transform: scale(.91); }
.tile-name {
  font-family: 'Archivo'; font-weight: 600; font-size: 11px; letter-spacing: -.005em;
  color: #2E352E; text-align: center; line-height: 1.25; max-width: 78px;
}

/* --------------------------------------------------------- thread list */

.rows { padding: 6px 0 30px; }
.row {
  width: 100%; border: 0; background: none; cursor: pointer;
  display: flex; gap: 12px; align-items: center;
  padding: 13px 16px; text-align: left;
  border-bottom: 1px solid #C9D0C7;
}
.row:active { background: #CDD4CB; }
.row-av {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  font-family: 'Archivo'; font-weight: 700; font-size: 15px;
}
.row-body { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 7px; }
.row-title { font-family: 'Archivo'; font-weight: 600; font-size: 15.5px; }
.row-sub { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.row-last {
  display: block; font-size: 13px; color: #626A5F; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ----------------------------------------------------------------- chat */

.field { flex: 1; overflow-y: auto; padding: 14px 12px 8px; }
.line { display: flex; gap: 8px; margin-bottom: 10px; align-items: flex-end; animation: rise .2s ease-out; }
.mine-line { justify-content: flex-end; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  font-family: 'Archivo'; font-weight: 700; font-size: 13px;
}
.bubble {
  max-width: 78%; padding: 9px 12px 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,.07); cursor: pointer;
}
.them { background: var(--bubble); border-radius: 14px 14px 14px 4px; }
.mine { background: var(--mine); color: var(--cream); border-radius: 14px 14px 4px 14px; }
.who {
  font-family: 'Archivo'; font-weight: 600; font-size: 12px;
  margin-bottom: 3px; display: flex; align-items: baseline; gap: 6px;
}
.where {
  font-family: 'Figtree'; font-weight: 400; font-size: 10px; color: #A6ABA2;
  letter-spacing: .04em; text-transform: uppercase;
}
.say { font-size: 15px; line-height: 1.45; }
.trans {
  margin-top: 7px; padding-top: 7px; border-top: 1px solid #E4E1D8;
  font-size: 13.5px; line-height: 1.4; color: var(--muted); font-style: italic;
}
.fix {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #4C574F;
  font-size: 14.5px; line-height: 1.45; color: #CFD6CD;
}
.fix .changed { color: var(--rose); font-weight: 500; }
.fixing { margin-top: 6px; font-size: 12.5px; color: #8E998F; font-style: italic; }

.dots { display: flex; gap: 4px; padding: 13px 14px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #9AA39B;
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.oops {
  font-size: 13px; color: #8C3A2E; background: #F3E2DE;
  padding: 8px 12px; border-radius: 10px; margin: 4px 0 10px 38px;
}

/* ------------------------------------------------------------ scene bits */

.scene { flex: 1; display: flex; min-height: 0; }
.tally {
  width: 128px; flex-shrink: 0; background: #CBD2C9;
  border-right: 1px solid #B9C1B7; padding: 12px 10px; overflow-y: auto;
}
.tally-title {
  font-family: 'Archivo'; font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; color: #5C6459; margin-bottom: 9px;
}
.tally-row {
  display: flex; justify-content: space-between; gap: 6px;
  font-size: 11.5px; line-height: 1.35; color: #3C433A;
  padding: 5px 0; border-bottom: 1px dotted #AEB6AC;
}
.tally-row b { font-weight: 600; white-space: nowrap; }
.tally-empty { font-size: 12px; color: #8A9187; }
.tally-total {
  display: flex; justify-content: space-between; margin-top: 10px;
  font-family: 'Archivo'; font-weight: 700; font-size: 12.5px; color: #26302B;
}
.tally-again {
  margin-top: 14px; width: 100%; border: 1px solid #8A9187; background: none;
  border-radius: 12px; padding: 6px; font-size: 11.5px;
  font-family: 'Archivo'; font-weight: 600; color: #4A5049; cursor: pointer;
}

/* ------------------------------------------------------------- input bar */

.accents {
  display: flex; gap: 6px; flex-shrink: 0;
  padding: 8px 10px 0; background: #C8CFC6;
}
.accent-key {
  flex: 1; border: 0; border-radius: 10px; padding: 7px 0;
  background: var(--bubble); color: #22271F;
  font-family: 'Figtree'; font-size: 15px; font-weight: 600; cursor: pointer;
}
.accent-key:active { background: #E4E1D8; }

.bar {
  display: flex; gap: 8px; flex-shrink: 0;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: #C8CFC6;
}
.input {
  flex: 1; border: 0; outline: 0; border-radius: 20px;
  padding: 12px 15px; font-size: 16px; font-family: 'Figtree';
  background: var(--bubble); color: #22271F; min-width: 0;
}
.input::placeholder { color: #9AA39B; }
.send {
  border: 0; border-radius: 20px; padding: 0 18px;
  background: #26302B; color: var(--cream);
  font-family: 'Archivo'; font-weight: 600; font-size: 14px; cursor: pointer;
}
.send:active { opacity: .7; }

/* ---------------------------------------------------------------- plain */

.plain { padding: 20px 18px 40px; }
.note { font-size: 14px; line-height: 1.5; color: #4A5049; margin: 0 0 18px; }
.note.small { font-size: 12.5px; color: var(--muted); margin-top: 16px; }
.wide {
  display: block; width: 100%; text-align: center; cursor: pointer;
  border: 0; border-radius: 14px; padding: 14px;
  background: #26302B; color: var(--cream);
  font-family: 'Archivo'; font-weight: 600; font-size: 15px; margin-bottom: 10px;
}
.wide.ghost { background: none; border: 1px solid #9AA39B; color: #3C433A; }

@media (prefers-reduced-motion: reduce) {
  .line, .dots i { animation: none; }
}

/* ------------------------------------------------------- sheets & settings */

.row-status {
  display: block; font-size: 11px; color: #8A9187;
  font-style: italic; margin-top: 2px;
}

.sheet-list { margin: 0 -18px 26px; }
.sheet { padding-bottom: 20px; }

.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block; font-family: 'Archivo'; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em; color: #4A5049; margin-bottom: 5px;
}
.field-label em {
  display: block; font-family: 'Figtree'; font-style: normal; font-weight: 400;
  font-size: 11.5px; text-transform: none; letter-spacing: 0; color: #8A9187; margin-top: 2px;
}
.field-input {
  width: 100%; border: 1px solid #BFC7BD; border-radius: 10px;
  padding: 10px 12px; font-size: 14.5px; line-height: 1.45;
  font-family: 'Figtree'; background: var(--bubble); color: #22271F;
  resize: none; overflow: hidden;
}
.field-input:focus { outline: 0; border-color: #7C8177; }

.sync { border-top: 1px solid #C3CAC1; padding-top: 18px; margin-top: 8px; }
.sync-label {
  font-family: 'Archivo'; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em; color: #4A5049; margin-bottom: 6px;
}
.sync-input { width: 100%; border: 1px solid #BFC7BD; border-radius: 12px; margin-bottom: 12px; }

.danger { border-top: 1px solid #C3CAC1; padding-top: 18px; margin-top: 8px; }
.danger-btn { border-color: #C9887B; color: #8C3A2E; }
.danger-btn.danger-confirm { background: #8C3A2E; border-color: #8C3A2E; color: #fff; font-size: 13px; }

.offline {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: #26302B; color: var(--cream); font-size: 12.5px;
  padding: 9px 16px; border-radius: 20px; z-index: 20;
}

/* --------------------------------------------------------------- libretto */

.libretto { margin: 0 -18px; }
.lib-sec { border-bottom: 1px solid #C9D0C7; padding: 0 18px; }
.lib-sum {
  cursor: pointer; padding: 13px 0; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.lib-sum::-webkit-details-marker { display: none; }
.lib-sum::after { content: '+'; font-size: 20px; color: #8A9187; font-weight: 400; flex-shrink: 0; }
.lib-sec[open] .lib-sum::after { content: '–'; }
.lib-sum-text { display: flex; flex-direction: column; gap: 2px; }
.lib-sum-it { font-family: 'Archivo'; font-weight: 600; font-size: 15px; color: #22271F; }
.lib-sum-en { font-size: 11.5px; color: #8A9187; }
.lib-body { padding: 0 0 18px; font-size: 14px; line-height: 1.55; color: #3C433A; }
.lib-body p { margin: 0 0 10px; }
.lib-note { font-size: 12.5px; color: var(--muted); font-style: italic; }
.lib-ex { font-size: 12.5px; color: var(--muted); margin-top: -6px !important; }
.lib-pair {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0 2px; border-bottom: 1px dotted #C9D0C7; font-size: 14px;
}

.lib-table { width: 100%; border-collapse: collapse; margin: 4px 0 14px; }
.lib-table th, .lib-table td {
  padding: 6px 8px; border-bottom: 1px solid #DCE1DA;
  text-align: left; font-size: 13.5px;
}
.lib-table th {
  font-family: 'Archivo'; font-weight: 600; color: #4A5049;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
}
.lib-table td:first-child { color: #626A5F; white-space: nowrap; }

/* ----------------------------------------------------------------- meteo */

.meteo-sum { font-style: italic; }
.meteo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.meteo-card {
  background: var(--bubble); border-radius: 16px; padding: 14px 14px 15px;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.meteo-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.meteo-top .face { margin-left: 0; }
.meteo-town { font-family: 'Archivo'; font-weight: 600; font-size: 14px; }
.meteo-temp { font-family: 'Archivo'; font-weight: 700; font-size: 30px; letter-spacing: -.02em; }
.meteo-cond { font-size: 13px; color: #4A5049; margin-top: 2px; }
.meteo-range { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------------- note */

.note-form { margin: -2px 0 18px; }
.note-input { display: block; width: 100%; margin-bottom: 10px; }
.note-empty { font-size: 13.5px; color: var(--muted); font-style: italic; }
.note-list { display: flex; flex-direction: column; gap: 8px; }
.note-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bubble); border-radius: 12px; padding: 11px 8px 11px 14px;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.note-card-main { flex: 1; min-width: 0; }
.note-front { font-family: 'Archivo'; font-weight: 600; font-size: 15px; }
.note-back { font-size: 13px; color: #626A5F; margin-top: 1px; }
.note-tag {
  display: inline-block; margin-top: 5px; font-size: 10.5px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid #C9D0C7; border-radius: 8px; padding: 1px 7px;
}
.note-del {
  border: 0; background: none; cursor: pointer; flex-shrink: 0;
  font-size: 22px; line-height: 1; color: #A6ABA2; padding: 4px 8px;
}
.note-del:active { color: #8C3A2E; }

/* --------------------------------------------------------------- bacheca */

.bacheca { padding: 18px 14px 30px; }
.bake-head { margin-bottom: 14px; }
.bake-head-title {
  font-family: 'Archivo'; font-weight: 700; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .06em; color: #8A6A3E;
}
.bake-head-date { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: capitalize; }

.bake-post {
  background: #F3EEDD; border: 1px solid #E3D8B8; border-radius: 14px;
  padding: 12px 14px 13px; margin-bottom: 12px;
}
.bake-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.bake-av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  font-family: 'Archivo'; font-weight: 700; font-size: 12px;
}
.bake-author { font-family: 'Archivo'; font-weight: 600; font-size: 13.5px; }
.bake-time { font-size: 11px; color: #9B8E6B; margin-left: auto; }
.bake-body { font-size: 14.5px; line-height: 1.5; color: #2E2A1E; white-space: pre-wrap; cursor: pointer; }

.bake-trans {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #E3D8B8;
  font-size: 13.5px; line-height: 1.45; color: #7A6A45; font-style: italic;
}

.bake-reply-toggle {
  margin-top: 10px; border: 1px solid #C9B98A; background: none; border-radius: 12px;
  padding: 5px 13px; font-family: 'Archivo'; font-weight: 600; font-size: 11.5px;
  color: #6B5433; cursor: pointer;
}
.bake-reply-toggle:active { background: #EBDFB9; }

.bake-replies { margin-top: 10px; padding-top: 9px; border-top: 1px dashed #D8CBA0; }
.bake-reply { font-size: 13px; margin-bottom: 6px; line-height: 1.4; color: #4A4128; }
.bake-reply b { font-family: 'Archivo'; font-weight: 600; margin-right: 5px; }
.bake-reply-form { display: flex; gap: 6px; margin-top: 4px; }
.bake-reply-input {
  flex: 1; border: 1px solid #D8CBA0; border-radius: 14px;
  padding: 7px 11px; font-size: 13.5px; font-family: 'Figtree'; background: #fff; min-width: 0;
}
.bake-reply-send {
  border: 0; border-radius: 14px; padding: 0 13px;
  background: #8A6A3E; color: #fff;
  font-family: 'Archivo'; font-weight: 600; font-size: 12.5px; cursor: pointer;
}

/* ----------------------------------------------------------------- radio */

.radio-owner {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 10px;
}
.radio-owner:first-child { margin-top: 0; }
.radio-owner .face { margin-left: 0; }
.radio-owner-name { font-family: 'Archivo'; font-weight: 700; font-size: 15px; }

.radio-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--bubble); border-radius: 14px;
  padding: 12px 14px 13px; margin-bottom: 9px;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.radio-card:active { background: #E4E1D8; }
.radio-title { font-family: 'Archivo'; font-weight: 600; font-size: 14.5px; }
.radio-blurb { font-size: 13px; color: #626A5F; margin-top: 3px; font-style: italic; }
