:root {
  --ink: #382b2b;
  --muted: #7b6965;
  --paper: #fbf2e7;
  --paper-deep: #f0dccb;
  --night: #241a1b;
  --night-2: #332426;
  --sage: #cfbd9d;
  --sage-dark: #745d4b;
  --gold: #dfa765;
  --rose: #c98f8d;
  --violet: #9a7f8f;
  --border: rgba(91, 62, 58, .16);
  --shadow: 0 28px 70px rgba(34, 18, 20, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 2%, rgba(223, 167, 101, .13), transparent 30rem),
    radial-gradient(circle at 7% 66%, rgba(201, 143, 141, .11), transparent 28rem),
    var(--night);
  color: #edf0e8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 92px;
  left: 0;
  right: 0;
  height: 610px;
  background:
    linear-gradient(90deg, rgba(35,24,25,.97) 0%, rgba(42,27,29,.82) 38%, rgba(35,22,24,.18) 76%, rgba(35,22,24,.34) 100%),
    linear-gradient(0deg, var(--night) 0%, transparent 42%),
    url("assets/cozy-village-hero-warm.png") center 43% / cover no-repeat;
  opacity: .86;
  pointer-events: none;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: relative;
  z-index: 2;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 43px;
  height: 43px;
  color: var(--gold);
}

.brand-mark svg { width: 100%; height: 100%; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 21px; letter-spacing: .02em; }
.brand small { display: block; color: #b7a49d; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; margin-top: 2px; }

.ghost-button, .secondary-button, .card-actions button, .save-button, .icon-button {
  color: inherit;
  background: transparent;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
}

.ghost-button { padding: 10px 14px; }
.ghost-button:hover { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.04); }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 5px; border-radius: 99px; background: rgba(255,255,255,.09); font-size: 12px; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; position: relative; z-index: 1; }

.hero { padding: 78px 0 74px; max-width: 650px; min-height: 440px; display: flex; flex-direction: column; justify-content: center; }
.eyebrow { color: #e3c59f; font-size: 12px; text-transform: uppercase; letter-spacing: .17em; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.eyebrow span { width: 28px; height: 1px; background: currentColor; }
.hero h1 { margin: 15px 0 16px; font: 400 clamp(50px, 7vw, 86px)/.95 Georgia, serif; letter-spacing: -.035em; }
.hero h1 em { color: var(--gold); font-weight: 400; }
.hero p { margin: 0; max-width: 590px; color: #eee0d5; font: 16px/1.7 Georgia, serif; text-shadow: 0 2px 14px rgba(24,10,12,.5); }

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding-bottom: 55px;
}

.controls-card {
  padding: 26px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 20px;
  background: rgba(50, 35, 36, .82);
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
  position: sticky;
  top: 18px;
  backdrop-filter: blur(14px);
}

.section-heading { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 27px; }
.section-heading h2, .drawer h2 { margin: 0 0 3px; font: 400 23px/1.1 Georgia, serif; }
.section-heading p { margin: 0; color: #b19c95; font-size: 12px; }
.step { color: var(--gold); font: 700 10px/1 monospace; letter-spacing: .08em; padding-top: 4px; }

.field-label, .mini-label { display: block; text-transform: uppercase; letter-spacing: .13em; font-size: 9px; font-weight: 800; }
.field-label { color: #b8a39a; margin: 18px 0 8px; }
.field-help { color: #9c8983; font-size: 10px; margin: 7px 0 0; }

input {
  width: 100%;
  color: #e4e8e0;
  background: rgba(5, 10, 6, .24);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
}
input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(175,197,159,.09); }
textarea { width: 100%; min-height: 88px; resize: vertical; color: var(--ink); background: #fffaf3; border: 1px solid rgba(91,62,58,.2); border-radius: 10px; padding: 11px 13px; outline: none; line-height: 1.45; }
textarea:focus { border-color: #bd806e; box-shadow: 0 0 0 3px rgba(201,143,141,.14); }
button:disabled { cursor: not-allowed; opacity: .38; }

fieldset { border: 0; padding: 0; margin: 0; }
.choice-group { margin-top: 20px; }
.choice-group .field-label { margin: 0 0 9px; padding: 0; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.option-grid button { min-height: 43px; display: flex; align-items: center; gap: 8px; padding: 9px 11px; color: #c2ada5; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(20,9,11,.18); font-size: 11px; text-align: left; }
.option-grid button span { width: 18px; color: #bc9c85; font-size: 15px; text-align: center; }
.option-grid button:hover { color: #d7ded4; border-color: rgba(175,197,159,.35); background: rgba(175,197,159,.05); }
.option-grid button.active { color: #392724; border-color: #dfbea0; background: #dfc4a8; font-weight: 750; box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.option-grid button.active span { color: #7e5749; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button { border: 0; color: #ae9992; background: transparent; border-radius: 7px; padding: 8px 3px; font-size: 11px; }
.segmented button.active { color: #3a2725; background: #d9b99f; font-weight: 750; }

.seed-row { display: grid; grid-template-columns: 1fr 42px; gap: 7px; }
.icon-button { min-width: 42px; min-height: 42px; }
.icon-button:hover { background: rgba(255,255,255,.05); }

.primary-button, .secondary-button { width: 100%; min-height: 46px; font-weight: 750; }
.primary-button { margin-top: 26px; color: #3b2822; border: 0; border-radius: 11px; background: linear-gradient(135deg, #e7b16f, #d99a82); box-shadow: 0 9px 24px rgba(213,145,112,.2); }
.primary-button:hover { background: linear-gradient(135deg, #edbc7f, #dfa08b); transform: translateY(-1px); }
.primary-button:active { transform: translateY(0); }
.secondary-button { margin-top: 9px; color: #b7c1b4; }
.secondary-button:hover { color: #fff; border-color: rgba(255,255,255,.28); }

.lock-summary { margin-top: 11px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 9px; color: #cdb9ad; background: rgba(224,168,113,.08); font-size: 10px; }
.lock-summary[hidden] { display: none; }
.lock-summary button { padding: 0; border: 0; color: #e0b37f; background: transparent; font: inherit; font-weight: 750; }
.lock-summary button:hover { color: #f2cfaa; }

.moss-card { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.09); }
.moss-art { width: 92px; height: 92px; object-fit: contain; flex: 0 0 auto; margin: -8px -5px -8px -10px; filter: drop-shadow(0 7px 12px rgba(10,4,5,.3)); }
.moss { width: 36px; height: 36px; position: relative; flex: 0 0 auto; display: grid; place-items: center; }
.moss-glow { position: absolute; inset: 4px; border-radius: 50%; background: rgba(230,173,98,.38); filter: blur(8px); }
.moss-body { position: relative; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50% 50% 45% 45%; color: #563f25; background: var(--gold); font-size: 10px; box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.moss-card strong { color: #eadbd0; font: 400 13px Georgia, serif; }
.moss-card p { margin: 4px 0 0; color: #ab9690; font: italic 11px/1.45 Georgia, serif; }

.demo-notice { margin: -5px 0 20px; padding: 10px 12px; border: 1px solid rgba(229,176,116,.25); border-radius: 10px; background: rgba(229,176,116,.08); }
.demo-notice strong, .demo-notice span { display: block; }
.demo-notice strong { color: #edc392; font: 400 14px Georgia, serif; }
.demo-notice span { margin-top: 2px; color: #ad9790; font-size: 10px; }

.village-card {
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 7%, rgba(226, 164, 139, .18), transparent 18rem),
    var(--paper);
  border-radius: 20px;
  padding: 36px 42px 30px;
  box-shadow: var(--shadow);
  min-height: 760px;
  overflow: hidden;
  position: relative;
}

.village-card::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  border: 1px solid rgba(87, 107, 83, .12);
  border-radius: 50%;
  right: -115px;
  top: 230px;
  box-shadow: 0 0 0 24px rgba(87,107,83,.025), 0 0 0 48px rgba(87,107,83,.018);
  pointer-events: none;
}

.village-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.keep-button { min-height: 38px; padding: 8px 10px; display: inline-flex; align-items: center; gap: 6px; color: #7b6965; border: 1px solid var(--border); border-radius: 10px; background: transparent; font-size: 10px; }
.keep-button:hover { border-color: rgba(149,96,82,.32); background: rgba(201,143,141,.08); }
.keep-button.locked { color: #7c4f43; border-color: #cf9a8c; background: #f1d9d0; }
.keep-button span { font-size: 13px; }
.village-title-wrap { display: flex; gap: 14px; align-items: flex-start; }
.village-header h2 { margin: 5px 0 5px; font: 400 clamp(38px, 5vw, 58px)/1 Georgia, serif; letter-spacing: -.035em; }
.village-header p { margin: 0; color: var(--muted); font: italic 14px/1.5 Georgia, serif; }
.card-kicker { color: #7b8578; text-transform: uppercase; font-size: 10px; letter-spacing: .15em; font-weight: 800; }
.save-button { color: var(--ink); border-color: var(--border); width: 38px; height: 38px; font-size: 22px; }
.save-button:hover, .save-button.saved { color: #a75b4d; border-color: #b78478; background: #f1ddd5; }

.tabs { display: flex; gap: 4px; padding: 18px 0 0; border-bottom: 1px solid var(--border); }
.tabs button { padding: 11px 13px; border: 0; border-bottom: 2px solid transparent; color: #788274; background: transparent; font-size: 11px; font-weight: 700; }
.tabs button:hover { color: #455241; }
.tabs button.active { color: #3d513b; border-bottom-color: #6f8968; }
.tabs button span { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 3px; border-radius: 99px; background: #e3e6da; font-size: 9px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.cast-layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 536px; }
.cast-list { padding: 20px 18px 8px 0; border-right: 1px solid var(--border); }
.resident-row { width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) 14px; align-items: center; gap: 10px; padding: 11px 9px; text-align: left; color: #536050; border: 0; border-radius: 11px; background: transparent; }
.resident-row:hover { background: rgba(89,111,82,.07); }
.resident-row.active { background: #e3e7d9; color: #354332; }
.resident-row > span:nth-child(2) { min-width: 0; }
.resident-row strong, .resident-row small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.resident-row strong { font: 400 14px Georgia, serif; }
.resident-row small { color: #879081; font-size: 9px; margin-top: 3px; }
.resident-avatar, .large-avatar { display: grid; place-items: center; border-radius: 50%; color: #fff9ed; background: var(--avatar); font-family: Georgia, serif; box-shadow: inset 0 0 0 3px rgba(255,255,255,.14); }
.resident-avatar { width: 36px; height: 36px; font-size: 14px; }
.row-arrow { color: #98a192; font: 20px Georgia, serif; }

.resident-detail { padding: 28px 0 8px 30px; }
.resident-identity { display: flex; align-items: center; gap: 14px; }
.large-avatar { width: 58px; height: 58px; flex: 0 0 auto; font-size: 23px; }
.resident-identity h3 { margin: 2px 0 3px; font: 400 28px/1 Georgia, serif; }
.resident-identity p { margin: 0; color: #657061; font: italic 13px Georgia, serif; }
.resident-detail .traits { padding: 18px 0; border-bottom: 1px solid var(--border); }
.resident-facts { display: grid; grid-template-columns: 1fr 1fr; }
.resident-facts section { min-height: 100px; padding: 18px 20px 15px 0; border-bottom: 1px solid var(--border); }
.resident-facts section:nth-child(odd) { border-right: 1px solid var(--border); }
.resident-facts section:nth-child(even) { padding-left: 20px; }
.resident-facts p, .connection p { margin: 0; color: #3f493c; font: 13px/1.45 Georgia, serif; }
.connection { padding: 18px 0; border-bottom: 1px solid var(--border); }
.resident-detail blockquote { display: flex; gap: 9px; margin: 0; padding: 18px 10px; color: #586452; }
.resident-detail blockquote span { color: var(--gold); font: 34px/1 Georgia, serif; }
.resident-detail blockquote p { margin: 5px 0 0; font: italic 14px/1.45 Georgia, serif; }

.problem-card { margin: 28px 0 14px; padding: 26px; border: 1px solid #d7c7a9; border-radius: 15px; background: #eee1c9; }
.problem-card h3 { margin: 5px 0 9px; font: 400 28px Georgia, serif; }
.problem-card p { margin: 0; color: #5e5a4d; font: 15px/1.55 Georgia, serif; }
.threads-list { display: grid; gap: 1px; }
.thread { display: grid; grid-template-columns: 34px 1fr; gap: 11px; padding: 21px 8px; border-bottom: 1px solid var(--border); }
.thread > span { color: #a07743; font: 700 10px monospace; padding-top: 4px; }
.thread p { margin: 0; color: #3f493c; font: 16px/1.5 Georgia, serif; }

.village-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 28px 0 24px; }
.village-notes section { padding: 18px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.26); }
.village-notes .detail-icon { margin-bottom: 14px; }
.village-notes p { margin: 0; color: #3f493c; font: 13px/1.5 Georgia, serif; }
.relationship-key { padding: 24px 0 10px; border-top: 1px solid var(--border); }
.relationship-key > div { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.relationship-key p { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--border); color: #4c5748; font: 12px/1.45 Georgia, serif; }

.block { position: relative; }
.lock-button {
  position: absolute;
  right: 0;
  top: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9ba194;
  opacity: .7;
  transition: opacity .15s, background .15s;
}
.block:hover > .lock-button, .lock-button.locked, .lock-button:focus { opacity: 1; }
.lock-button:hover { color: #995f50; background: rgba(180,109,91,.1); }
.lock-button.locked { color: #884f43; background: #efd4ca; }
.problem-card > .lock-button { right: 12px; top: 12px; }
.village-notes .lock-button { right: 10px; top: 10px; }
.resident-identity { position: relative; padding-right: 35px; }
.resident-identity > .lock-button { right: 0; top: 3px; }
.resident-row .kept-marker { color: #b16e5d; font-size: 12px; }

.identity { display: flex; align-items: center; gap: 19px; padding: 32px 0 22px; }
.portrait { width: 68px; height: 68px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #f6eedd; background: #63765d; font: 400 28px Georgia, serif; box-shadow: inset 0 0 0 5px rgba(255,255,255,.13); }
.identity h2 { margin: 0 0 5px; font: 400 clamp(31px, 4vw, 47px)/1 Georgia, serif; letter-spacing: -.025em; }
.identity p { margin: 0; color: var(--muted); font-size: 12px; }
.dot { margin: 0 7px; color: #b3aa99; }

.role-line, .trait-block { padding: 18px 30px 18px 0; border-top: 1px solid var(--border); }
.mini-label { color: #7b8578; margin-bottom: 6px; }
.role-line strong { font: italic 21px/1.3 Georgia, serif; color: #4a5947; }
.traits { display: flex; flex-wrap: wrap; gap: 7px; }
.trait { padding: 7px 11px; border: 1px solid #c8cdbf; border-radius: 999px; color: #485345; font-size: 11px; background: rgba(255,255,255,.28); }

.details-grid { border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; }
.detail { min-height: 122px; display: flex; align-items: flex-start; gap: 13px; padding: 23px 32px 20px 0; border-bottom: 1px solid var(--border); }
.detail:nth-child(odd) { border-right: 1px solid var(--border); }
.detail:nth-child(even) { padding-left: 28px; }
.detail p { margin: 0; max-width: 260px; color: #3d483a; font: 15px/1.45 Georgia, serif; }
.detail-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; flex: 0 0 auto; font-size: 13px; }
.detail-icon.warm { color: #955f29; background: #f0ddbf; }
.detail-icon.cool { color: #8b665a; background: #edddd4; }
.detail-icon.violet { color: #7b5b69; background: #eadbe0; }
.detail-icon.green { color: #4d684c; background: #dce7d5; }

.hook { padding: 24px 34px 24px 0; border-bottom: 1px solid var(--border); }
.hook p { margin: 0; color: #3d483a; font: 16px/1.5 Georgia, serif; }
.quote { margin: 0; padding: 26px 38px; display: flex; gap: 11px; color: #5b6656; }
.quote > span { color: var(--gold); font: 38px/1 Georgia, serif; }
.quote p { margin: 6px 0 0; font: italic 17px/1.45 Georgia, serif; }

.card-actions { padding-top: 21px; display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions button { color: #536050; border-color: var(--border); padding: 9px 13px; font-size: 11px; }
.card-actions button:hover { background: rgba(76, 98, 72, .08); border-color: rgba(50,70,48,.32); }
.demo-upgrade { margin-top: 18px; padding: 16px 18px; border: 1px solid #d9b08e; border-radius: 13px; background: linear-gradient(135deg, #f6dfc5, #f0d3ce); color: #593c38; }
.demo-upgrade strong { font: 400 17px Georgia, serif; }
.demo-upgrade p { margin: 5px 0 0; color: #745953; font: 12px/1.5 Georgia, serif; }

.drawer {
  position: fixed;
  z-index: 30;
  right: 0;
  top: 0;
  width: min(420px, 100%);
  height: 100vh;
  padding: 28px;
  background: #202820;
  box-shadow: -28px 0 70px rgba(0,0,0,.38);
  transform: translateX(105%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.drawer-header .mini-label { color: var(--sage); }
.saved-list { display: grid; gap: 11px; padding-top: 20px; }
.saved-item { padding: 16px; border: 1px solid rgba(255,255,255,.11); border-radius: 13px; background: rgba(255,255,255,.025); }
.saved-item h3 { margin: 0 0 4px; font: 400 19px Georgia, serif; }
.saved-item p { margin: 0; color: #98a396; font-size: 11px; }
.saved-actions { display: flex; gap: 7px; margin-top: 13px; }
.saved-actions button { color: #bec7bb; background: transparent; border: 1px solid rgba(255,255,255,.12); padding: 6px 9px; border-radius: 8px; font-size: 10px; }
.empty-state { color: #899487; font: italic 15px/1.5 Georgia, serif; text-align: center; padding: 60px 20px; }
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }

.modal { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; color: var(--ink); border: 1px solid rgba(91,62,58,.18); border-radius: 20px; background: var(--paper); box-shadow: 0 32px 90px rgba(20,8,10,.5); }
.modal::backdrop { background: rgba(25,14,16,.7); backdrop-filter: blur(5px); }
.modal-shell { display: flex; flex-direction: column; max-height: calc(100vh - 30px); }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 26px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 4px 0 0; font: 400 27px Georgia, serif; }
.modal-close { width: 36px; height: 36px; flex: 0 0 auto; color: #765f5b; border: 1px solid var(--border); border-radius: 50%; background: transparent; font-size: 23px; line-height: 1; }
.modal-body { padding: 24px 26px; overflow-y: auto; }
.modal-footer { border-top: 1px solid var(--border); color: #88736c; font-size: 11px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 28px; }
.help-grid section { padding-left: 14px; border-left: 2px solid #dfb17e; }
.help-grid h3 { margin: 0 0 6px; color: #4c3937; font: 400 18px Georgia, serif; }
.help-grid p { margin: 0; color: #75635e; font: 13px/1.55 Georgia, serif; }
.secondary-modal-button, .primary-modal-button, .text-button { padding: 9px 13px; border-radius: 9px; }
.secondary-modal-button { color: #594946; border: 1px solid var(--border); background: transparent; }
.primary-modal-button { color: #3b2822; border: 0; background: linear-gradient(135deg, #e7b16f, #d99a82); font-weight: 750; }
.text-button { color: #806c66; border: 0; background: transparent; }
.edit-modal { width: min(820px, calc(100% - 28px)); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.edit-grid label > span { display: block; margin: 0 0 6px; color: #76625d; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.edit-grid input { color: var(--ink); background: #fffaf3; border-color: rgba(91,62,58,.2); }
.edit-grid .wide { grid-column: 1 / -1; }
.edit-divider { margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--border); }
.edit-divider strong { display: block; margin-top: 4px; font: 400 19px Georgia, serif; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; color: #1d241c; background: var(--sage); padding: 10px 16px; border-radius: 10px; box-shadow: 0 14px 32px rgba(0,0,0,.25); font-size: 12px; font-weight: 750; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.site-footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 38px; border-top: 1px solid rgba(255,255,255,.08); color: #727d70; display: flex; justify-content: space-between; font: italic 12px Georgia, serif; position: relative; z-index: 1; }

@media (max-width: 820px) {
  body::before { height: 560px; background-position: 58% 45%; opacity: .66; }
  .hero { padding-top: 52px; min-height: 410px; }
  .workspace { grid-template-columns: 1fr; }
  .controls-card { position: static; }
  .village-card { min-height: 0; }
}

@media (max-width: 580px) {
  .topbar, main, .site-footer { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 76px; }
  .brand small { display: none; }
  .topbar-actions { gap: 4px; }
  .ghost-button { padding: 9px 10px; font-size: 0; }
  .ghost-button span { font-size: 14px; }
  body::before { top: 76px; height: 540px; background-position: 66% center; opacity: .52; }
  .hero { padding: 45px 5px 42px; min-height: 430px; }
  .hero h1 { font-size: 47px; }
  .controls-card { padding: 22px; }
  .village-card { padding: 27px 23px 24px; }
  .village-header h2 { font-size: 37px; }
  .village-header { gap: 10px; }
  .keep-button { width: 38px; padding: 0; justify-content: center; font-size: 0; }
  .keep-button span { font-size: 13px; }
  .tabs { overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .cast-layout { grid-template-columns: 1fr; }
  .cast-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding-right: 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .resident-detail { padding-left: 0; }
  .village-notes, .relationship-key > div { grid-template-columns: 1fr; }
  .details-grid { grid-template-columns: 1fr; }
  .detail:nth-child(odd) { border-right: 0; }
  .detail:nth-child(even) { padding-left: 0; }
  .identity { align-items: flex-start; }
  .portrait { width: 55px; height: 55px; }
  .identity h2 { font-size: 31px; }
  .site-footer { display: block; line-height: 1.8; }
  .site-footer span { display: block; }
  .help-grid, .edit-grid { grid-template-columns: 1fr; }
  .edit-grid .wide { grid-column: auto; }
  .modal-header, .modal-footer, .modal-body { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 430px) {
  .cast-list { grid-template-columns: 1fr; }
  .resident-facts { grid-template-columns: 1fr; }
  .resident-facts section:nth-child(odd) { border-right: 0; }
  .resident-facts section:nth-child(even) { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
