/* PHH Site: light, calm, big touch targets. PHH green for actions; label colours only on labels. */
:root {
  --green: #015e46; --green-hover: #01503c; --green-soft: #e6f2ee; --green-text: #01543f;
  --text: #16181b; --text2: #3d434a; --muted: #6b737c; --line: #e3e6ea; --line-strong: #cfd4da;
  --fill: #f3f5f7; --fill-hover: #e9ecef; --paper: #ffffff; --danger: #b42318; --warn-bg: #fff6e5; --warn: #8a5300;
  --sel: #2563eb;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .38; cursor: default; }
#app { height: 100%; }

/* ---------- shared bits */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
       border-radius: 12px; font-weight: 600; background: var(--fill); color: var(--text); }
.btn:active { background: var(--fill-hover); }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { background: var(--green-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
        background: var(--fill); color: var(--text2); white-space: nowrap; }
.chip.ok { background: var(--green-soft); color: var(--green-text); }
.chip.wait { background: var(--warn-bg); color: var(--warn); }
.chip.err { background: #fdecea; color: var(--danger); }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.field { display: block; margin: 0 0 16px; }
.field span { display: block; font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.field input { width: 100%; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff;
               font: inherit; font-size: 17px; color: var(--text); outline: none; }
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(1,94,70,.15); }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; }
.msg { font-size: 14px; color: var(--danger); min-height: 20px; }

/* ---------- sign in */
.signin { max-width: 420px; margin: 0 auto; padding: calc(48px + var(--safe-top)) 24px 32px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand img { width: 52px; height: 52px; border-radius: 12px; }
.brand b { display: block; font-size: 22px; }
.brand small { color: var(--muted); }
.signin p { color: var(--text2); margin: 0 0 22px; }

/* ---------- home */
.home { max-width: 720px; margin: 0 auto; padding: calc(12px + var(--safe-top)) 16px calc(32px + var(--safe-bottom)); }
.home header { display: flex; align-items: center; gap: 12px; padding: 8px 0 14px; }
.home header img { width: 40px; height: 40px; border-radius: 10px; }
.home header .who { flex: 1; min-width: 0; }
.home header .who b { display: block; font-size: 19px; }
.home header .who small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.iconbtn:active { background: var(--fill); }
.iconbtn svg { width: 22px; height: 22px; }
.banner { border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; display: flex; gap: 12px; align-items: center; background: var(--warn-bg); color: var(--warn); font-size: 15px; }
.banner.info { background: var(--fill); color: var(--text2); }
.banner div { flex: 1; }
.banner .btn { min-height: 36px; padding: 0 12px; font-size: 14px; background: rgba(255,255,255,.7); }
.newbtn { width: 100%; min-height: 56px; font-size: 17px; margin: 4px 0 22px; border-radius: 14px; }
.home h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--fill); text-align: left; width: 100%; }
.card:active { background: var(--fill-hover); }
.card .t { flex: 1; min-width: 0; }
.card b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.card .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.footnote { color: var(--muted); font-size: 13px; text-align: center; margin-top: 22px; }

/* ---------- editor */
.editor { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; background: var(--paper); }
.topbar { display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 6px calc(8px + var(--safe-left));
          border-bottom: 1px solid var(--line); background: #fff; z-index: 3; }
.topbar .title { flex: 1; min-width: 0; padding: 0 4px; }
.topbar .title b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn.primary { min-height: 40px; padding: 0 14px; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #fff; }
.stage canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 100px); background: rgba(22,24,27,.86); color: #fff;
        font-size: 14px; padding: 7px 12px; border-radius: 12px; pointer-events: none; text-align: center; z-index: 2;
        display: flex; align-items: center; gap: 10px; width: max-content; }
.hint svg { width: 40px; height: 40px; flex: none; }
.hint svg + span { text-align: left; }
.hint:empty { display: none; }
.stage.busy .hint { opacity: .15; transition: opacity .15s; }
.ctxbar .btn.snap { gap: 5px; padding: 0 10px; color: var(--text2); }
.ctxbar .btn.snap svg { width: 16px; height: 16px; }
.fitbtn { position: absolute; top: 8px; right: calc(8px + var(--safe-right)); background: rgba(255,255,255,.92); box-shadow: 0 1px 4px rgba(0,0,0,.15); z-index: 2; }
.readonly { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2; }
.ctxbar { display: flex; align-items: center; gap: 6px; padding: 6px calc(8px + var(--safe-right)) 6px calc(8px + var(--safe-left)); overflow-x: auto;
          border-top: 1px solid var(--line); background: #fff; min-height: 52px; scrollbar-width: none; }
.ctxbar::-webkit-scrollbar { display: none; }
.ctxbar .btn { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; flex: none; }
.ctxbar .btn.on { background: var(--green-soft); color: var(--green-text); box-shadow: inset 0 0 0 1.5px var(--green); }
.ctxbar .spacer { flex: 1; min-width: 4px; }
.ctxbar .step { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; padding: 0 2px; flex: none; }
.ctxbar .step b { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
                  background: var(--fill); font-size: 12px; color: var(--muted); }
.ctxbar .step.now { color: var(--green-text); font-weight: 700; }
.ctxbar .step.now b { background: var(--green); color: #fff; }
.ctxbar .step.done b { background: var(--green-soft); color: var(--green-text); }
.ctxbar .btn svg { width: 18px; height: 18px; }
.ctxbar .note { color: var(--muted); font-size: 14px; white-space: nowrap; padding: 0 4px; }
.toolbar { display: flex; justify-content: center; gap: 2px; padding: 4px calc(4px + var(--safe-right)) calc(4px + var(--safe-bottom)) calc(4px + var(--safe-left));
           background: #fff; border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.tool { flex: 1 1 0; min-width: 0; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px;
        border-radius: 12px; font-size: 11px; font-weight: 600; color: var(--text2); }
.tool svg { width: 24px; height: 24px; }
.tool span { white-space: nowrap; }
.tool.on { background: var(--green); color: #fff; }

/* ---------- sheets (dialogs from the bottom on phones, centred on tablets) */
.scrim { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,18,22,.42); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 20px 20px calc(20px + var(--safe-bottom));
         box-shadow: 0 -6px 30px rgba(0,0,0,.18); max-height: 90%; overflow-y: auto; }
@media (min-width: 700px) and (min-height: 560px) { .scrim { align-items: center; } .sheet { border-radius: 18px; padding-bottom: 20px; } }
.sheet h3 { margin: 0 0 8px; font-size: 20px; }
.sheet p { margin: 0 0 16px; color: var(--text2); }
.sheet .buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.sheet .buttons .btn { flex: 1 1 auto; }
.sheet .menu { display: flex; flex-direction: column; gap: 4px; }
.sheet .menu .btn { justify-content: flex-start; background: transparent; padding: 0 8px; }
.sheet .menu .btn:active { background: var(--fill); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); background: #16181b; color: #fff;
         padding: 12px 18px; border-radius: 14px; z-index: 60; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100% - 32px); text-align: center; }
.statusrow { display: flex; gap: 8px; margin-bottom: 14px; }
.statusrow .btn { flex: 1; flex-direction: column; gap: 4px; min-height: 64px; font-size: 13px; }
.statusrow .btn.on { background: var(--green-soft); color: var(--green-text); box-shadow: inset 0 0 0 1.5px var(--green); }
