:root {
  --navy: #1f3b4d; --navy-deep: #152a38; --ink: #1d2b36; --muted: #5b6873; --teal: #2f6f73;
  --gold: #b8864b; --gold-soft: #d9a866; --bg: #f4f1ec; --card: #ffffff; --line: #e4dacb;
  --ok: #2e7d4f; --warn: #a3651f; --err: #a3341f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--teal); }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; color: var(--navy); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.8rem; } h2 { font-size: 1.15rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); cursor: pointer; text-decoration: underline; }
.linklike.danger { color: var(--err); }

.p-top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; background: var(--navy-deep); color: #fff; padding: 10px 24px; position: sticky; top: 0; z-index: 10; }
.p-brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-family: 'Fraunces', serif; font-size: 1.15rem; font-weight: 600; }
.p-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.p-nav a { color: #d6e0e6; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.p-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.p-nav a[aria-current="page"] { background: rgba(217,168,102,.18); color: var(--gold-soft); }
.p-user { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.p-user a, .p-user .linklike { color: #d6e0e6; }
.p-main { max-width: 1240px; margin: 0 auto; padding: 24px; }

.p-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.p-head h1 { margin: 0; }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.p-actions form { margin: 0; }
.p-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.p-span2 { min-width: 0; }
@media (max-width: 900px) { .p-grid { grid-template-columns: 1fr; } .p-main { padding: 16px; } .p-user { margin-left: 0; } }
.p-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.p-card > :last-child { margin-bottom: 0; }

.p-btn { display: inline-block; background: var(--gold); color: #fff; border: 2px solid var(--gold); border-radius: 999px; padding: 9px 18px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.p-btn:hover { background: #a37438; border-color: #a37438; color: #fff; }
.p-btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.p-btn-ghost:hover, .p-btn-ghost[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

.p-table { width: 100%; border-collapse: collapse; }
.p-table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px; }
.p-table td { border-bottom: 1px solid #f0ebe3; padding: 10px 8px; vertical-align: top; }
.p-table tr.is-done td { color: var(--muted); }
@media (max-width: 700px) { .p-table thead { display: none; } .p-table td { display: block; border: 0; padding: 2px 0; } .p-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); } }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: #eef1f3; color: var(--muted); }
.tag-open { background: #fbefdc; color: var(--warn); }
.tag-done { background: #e3f2e8; color: var(--ok); }

.msg { padding: 10px 14px; border-radius: 10px; background: #eef4f4; border-left: 4px solid var(--teal); margin: 0 0 12px; }
.msg-success { background: #e8f4ec; border-color: var(--ok); }
.msg-warning { background: #fbf1e2; border-color: var(--warn); }
.msg-error { background: #fbe9e5; border-color: var(--err); }

.p-dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; margin: 0 0 18px; }
.p-dl dt { color: var(--muted); } .p-dl dd { margin: 0; }
.p-message { background: #faf8f4; border-radius: 10px; padding: 14px 16px; white-space: normal; }

.p-form fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.p-form legend { font-family: 'Fraunces', serif; font-weight: 600; color: var(--navy); font-size: 1.1rem; margin-bottom: 8px; }
.p-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .p-row { grid-template-columns: 1fr; } .p-dl { grid-template-columns: 1fr; } }
.p-field { margin-bottom: 12px; }
.p-field label, .p-login label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; color: var(--navy); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink); background: #fff; border: 1px solid #cdbfa9; border-radius: 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,115,.3); border-color: var(--teal); }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--err); font-size: .88rem; }
.p-login { max-width: 400px; margin: 60px auto; }
.p-login input { margin-bottom: 12px; }

.p-party { border-bottom: 1px solid #f0ebe3; padding-bottom: 12px; margin-bottom: 12px; }
.p-party p { margin: 0 0 6px; }
.p-copy { display: flex; gap: 6px; }
.p-copy input { font-size: .8rem; }

/* Agreement document (shared by portal preview) */
.p-doc h2 { font-size: 1.5rem; }
.p-doc h3, .agreement-doc h3 { font-size: 1.02rem; margin-top: 1.4em; }
.doc-meta { color: var(--muted); font-size: .85rem; }
.doc-quote { background: #faf8f4; border-left: 3px solid var(--gold); padding: 8px 12px; }

/* Notes */
.note-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.note-title { flex: 1 1 320px; font-family: 'Fraunces', serif; font-size: 1.4rem !important; font-weight: 600; color: var(--navy); border-color: transparent !important; background: transparent !important; padding-left: 0 !important; }
.note-title:focus { border-color: #cdbfa9 !important; background: #fff !important; padding-left: 12px !important; }
.note-bar select { width: auto; max-width: 260px; }
.note-tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.note-tabs button { background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 9px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.note-tabs button[aria-selected="true"] { background: var(--card); border-color: var(--line); color: var(--navy); }
.note-panel { border-top-left-radius: 0; }
.note-paper { min-height: 62vh; border: 0 !important; outline: none !important; resize: vertical; font-size: 1.02rem; line-height: 1.8;
  background: repeating-linear-gradient(#fff, #fff 1.75rem, #eef2f5 1.75rem, #eef2f5 calc(1.75rem + 1px)) !important; background-attachment: local !important; }
.draw-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.draw-tools label { display: flex; gap: 6px; align-items: center; font-weight: 600; font-size: .9rem; }
.draw-tools input[type=color] { width: 38px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; }
#draw-canvas { width: 100%; height: auto; aspect-ratio: 16 / 10; border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; background: #fff; display: block; }
.drop-zone { border: 2px dashed #cdbfa9; border-radius: 12px; padding: 28px; text-align: center; background: #faf8f4; margin-bottom: 16px; }
.drop-zone.is-over { border-color: var(--teal); background: #eef4f4; }
.att-list { list-style: none; padding: 0; margin: 0; }
.att-list li { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid #f0ebe3; }
.att-list form { margin-left: auto; }
