:root {
  --orange: #d96f32;
  --orange-dark: #a8481f;
  --cream: #fff8e9;
  --cream-deep: #f6ead1;
  --green: #153b32;
  --charcoal: #252b29;
  --muted: #66716d;
  --line: #d9d2c2;
  --surface: #ffffff;
  --danger: #9e2f28;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(37, 43, 41, .08);
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body {
  margin: 0;
  overflow-x: hidden;
  color: var(--charcoal);
  background: linear-gradient(180deg, #fff4df 0, var(--cream) 280px, #f8f6ef 100%);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.wrap { width: min(100%, 1280px); margin: 0 auto; padding-inline: 28px; }

.topbar { padding: 34px 0 26px; background: var(--green); color: white; border-bottom: 6px solid var(--orange); }
h1 { max-width: 900px; margin: 0; font: 750 clamp(1.85rem, 3.2vw, 3.25rem)/1.12 Georgia, serif; }
.top-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 24px; }
#save-status { color: #dce8e3; font-size: .86rem; }

.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px;
  padding: 9px 15px; border: 1px solid transparent; border-radius: 8px;
  font-weight: 750; text-decoration: none;
}
.button-accent { background: var(--orange); color: #1d211f; border-color: #f2a371; }
.button-dark { background: var(--green); color: white; }
.button-quiet { background: var(--cream); color: var(--green); border-color: var(--line); }
.button-danger { margin-top: 8px; background: transparent; color: var(--danger); border-color: #d9aaa6; }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, .matrix-scroll:focus-visible {
  outline: 3px solid rgba(217, 111, 50, .38); outline-offset: 2px;
}

#persona-list { padding: 34px 0 10px; }
.persona { margin-bottom: 22px; overflow: clip; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.persona-summary {
  display: flex; align-items: center; gap: 16px; min-height: 88px; padding: 17px 22px;
  color: white; background: var(--green); list-style: none; cursor: pointer;
}
.persona-summary::-webkit-details-marker { display: none; }
.persona-number { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border: 2px solid var(--orange); border-radius: 50%; color: #ffc099; font-weight: 800; }
.summary-text { display: grid; flex: 1; min-width: 0; gap: 3px; }
.summary-text strong { font: 700 1.15rem/1.25 Georgia, serif; }
.summary-text small { overflow: hidden; color: #dce8e3; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: #ffc099; transition: transform .18s ease; }
.persona:not([open]) .chevron { transform: rotate(-90deg); }
.persona-body { padding: 26px; }

h2, h3 { margin: 0; color: var(--green); font-family: Georgia, serif; line-height: 1.25; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.14rem; }
.context-card, .bank, .matrix-section { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.context-card { padding: 20px; }
.context-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 18px 0 8px; }
.persona-field { display: grid; min-width: 0; gap: 6px; color: var(--green); font-weight: 750; }
.persona-field .editable { font-weight: 400; }

input, textarea, select {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px;
  background: #fffdfa; color: var(--charcoal); padding: 10px 11px; line-height: 1.45;
}
textarea { resize: vertical; }
.suggested input, .suggested textarea, .suggested select { opacity: .5; }
.suggested input:focus, .suggested textarea:focus, .suggested select:focus { opacity: .5; }
.edited input, .edited textarea, .edited select { opacity: 1; border-color: var(--orange); background: #fff; }

.banks-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.bank { padding: 18px; background: var(--cream); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.count { padding: 3px 9px; border-radius: 999px; background: var(--cream-deep); color: var(--green); font-size: .78rem; font-weight: 800; }
.bank-list { margin: 0 0 14px; padding-left: 28px; }
.bank-row { margin-bottom: 9px; padding-left: 4px; }
.bank-row::marker { color: var(--orange-dark); font-weight: 800; }
.bank-row textarea { display: inline-block; width: calc(100% - 96px); vertical-align: top; opacity: .5; }
.bank-row textarea:focus { opacity: .5; }
.bank-row textarea.edited { opacity: 1; border-color: var(--orange); }
.icon-button { width: 88px; min-height: 42px; margin-left: 8px; border: 0; background: transparent; color: var(--danger); font-size: .76rem; font-weight: 750; }

.matrix-section { margin-top: 18px; padding: 18px; }
.matrix-section > h3 { margin-bottom: 14px; }
.matrix-scroll { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; overscroll-behavior-inline: contain; }
.matrix-table { width: 100%; min-width: 2460px; border-collapse: collapse; table-layout: fixed; background: white; }
.matrix-table th, .matrix-table td { width: 270px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; text-align: left; }
.matrix-table th { position: sticky; top: 0; z-index: 1; background: var(--green); color: white; font-size: .82rem; line-height: 1.3; }
.matrix-table tr:last-child td { border-bottom: 0; }
.matrix-table td:last-child, .matrix-table th:last-child { border-right: 0; }
.matrix-table textarea { min-height: 116px; }
.desire-link { margin-bottom: 8px; background: var(--cream); font-size: .8rem; }
.marketing-column { background: #f7f4eb; color: var(--muted); }
.matrix-table th.marketing-column { background: #31544b; color: #e3e9e6; }

.submit-panel {
  display: flex; align-items: center; justify-content: flex-start; gap: 24px;
  margin: 16px 0 54px; padding: 22px; border: 1px solid var(--line); border-top: 4px solid var(--orange);
  border-radius: var(--radius); background: white; box-shadow: var(--shadow);
}
.submit-actions { display: flex; align-items: center; gap: 14px; }
#submit-status { min-width: 110px; color: var(--green); font-weight: 750; }
.empty-state { padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

@media (max-width: 820px) {
  .wrap { padding-inline: 18px; }
  .top-actions, .submit-panel { align-items: stretch; flex-direction: column; }
  .context-grid, .banks-grid { grid-template-columns: 1fr; }
  .persona-body { padding: 18px; }
  .summary-text small { white-space: normal; }
}

@media print {
  .top-actions, .button, .icon-button, .submit-panel { display: none !important; }
  .persona { break-inside: avoid; box-shadow: none; }
  .persona:not([open]) .persona-body { display: block; }
}
