/* ============================================================
   Living Palm — mystic ink theme (indigo night, gold lines)
   ============================================================ */
:root {
    --bg: #0d0816;
    --panel: rgba(30,20,52,.82);
    --panel2: rgba(20,14,38,.92);
    --line: rgba(190,150,240,.16);
    --line2: rgba(190,150,240,.32);
    --ink: #f2ecfa;
    --dim: #b8a8d0;
    --faint: #7d6f99;
    --gold: #e8c878;
    --vio: #c9a0f0;
    --vio2: #8a5cc0;
    --pink: #f0a8c8;
    --good: #a8e0b8;
    --warn: #f0c080;
    --rad: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    margin: 0; overflow: hidden; color: var(--ink);
    font: 14px/1.5 'Segoe UI', 'Inter', system-ui, sans-serif;
    background:
        radial-gradient(120% 90% at 70% -10%, #241640 0%, transparent 55%),
        radial-gradient(90% 70% at 10% 110%, #181030 0%, transparent 50%),
        var(--bg);
}
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------------- topbar ---------------- */
#topbar {
    position: relative; z-index: 30; display: flex; align-items: center; gap: 8px;
    padding: 10px 14px 6px;
    pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { font: 700 15px 'Segoe UI'; letter-spacing: .04em; color: var(--dim); }
.brand b {
    background: linear-gradient(120deg, #f0e0ff, var(--vio) 60%, var(--gold));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#liveChip, #handChip, #scoreChip { white-space: nowrap; }
.icon-btn {
    border: 1px solid var(--line); background: rgba(34,24,58,.55); color: var(--dim);
    font-size: 13px; padding: 6px 9px; border-radius: 11px; cursor: pointer; margin-left: auto;
}
.icon-btn + .icon-btn { margin-left: 0; }
.icon-btn:hover { color: #fff; border-color: var(--line2); }
.icon-btn.sm { font-size: 11px; padding: 4px 8px; margin-left: 0; }

/* ---------------- chips row ---------------- */
#chips { position: relative; z-index: 30; display: flex; gap: 7px; padding: 2px 14px 8px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line); background: rgba(34,24,58,.55); color: var(--dim);
    font: 700 10px 'Segoe UI'; letter-spacing: .09em; padding: 7px 11px; border-radius: 12px;
    cursor: pointer; transition: all .18s;
}
.chip:hover { color: #fff; border-color: var(--line2); background: rgba(140,90,200,.22); }
.chip-amber { color: var(--gold); border-color: rgba(232,200,120,.35); }

/* ---------------- stage ---------------- */
#stage { position: relative; flex: 1; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#content {
    position: absolute; inset: 0; overflow-y: auto; display: none;
    padding: 6px 16px 90px; max-width: 860px; margin: 0 auto;
    scrollbar-width: thin; scrollbar-color: var(--vio2) transparent;
}
#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-thumb { background: rgba(150,100,210,.3); border-radius: 3px; }

/* ---------------- dom content ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 9px; margin: 6px 0 12px; }
.kpi {
    background: linear-gradient(160deg, rgba(150,100,220,.16), rgba(26,18,48,.7));
    border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; text-align: center;
}
.kpi b { display: block; font: 800 22px Georgia, serif; color: var(--vio); text-shadow: 0 0 18px rgba(200,150,240,.4); }
.kpi span { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.card {
    position: relative; background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--rad); padding: 13px 15px; margin-bottom: 10px;
    backdrop-filter: blur(6px);
}
.card::before {
    content: attr(data-glyph); position: absolute; right: 12px; top: 10px;
    font-size: 20px; opacity: .45;
}
.card > b { display: block; font: 700 13.5px 'Segoe UI'; color: #f4ecfc; margin-bottom: 4px; }
.card > span { display: block; font-size: 12.5px; color: var(--dim); }
.card i { color: #c9b8e0; font-style: normal; opacity: .85; }
.tb { background: var(--panel); border: 1px solid var(--line); border-radius: var(--rad); padding: 6px 12px; margin-bottom: 10px; }
.row {
    display: flex; align-items: baseline; gap: 10px; padding: 8px 2px;
    border-bottom: 1px solid rgba(190,150,240,.08); font-size: 12.5px;
}
.row:last-child { border-bottom: 0; }
.row b { color: var(--vio); font: 700 12px 'Segoe UI'; min-width: 90px; }
.row span { color: var(--dim); }
.row em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--faint); text-align: right; max-width: 55%; }
/* evidence badges — measured / leaning / tradition / not seen */
.badge {
    display: inline-block; font-style: normal; font-size: 9px; letter-spacing: .06em;
    padding: 1px 7px; border-radius: 9px; border: 1px solid; margin-left: 6px;
    vertical-align: 1px; white-space: nowrap;
}
.b-meas { color: #8fe0a8; border-color: rgba(90,200,130,.45); background: rgba(60,180,110,.09); }
.b-lean { color: #e8c878; border-color: rgba(220,180,90,.4); background: rgba(220,180,90,.07); }
.b-trad { color: #a898c8; border-color: rgba(160,130,220,.3); background: rgba(140,120,190,.06); }
.b-abs  { color: #7a6a98; border-color: rgba(120,105,150,.35); background: transparent; }
.card input, .card select {
    width: 100%; background: #140c24; color: var(--ink); border: 1px solid var(--line);
    border-radius: 11px; padding: 9px 11px; font: 13.5px 'Segoe UI'; margin-bottom: 7px; color-scheme: dark;
}
.card input:focus { outline: none; border-color: rgba(190,150,240,.6); }
.card input[type="file"] { padding: 8px 9px; }
.btn {
    display: inline-block; padding: 10px 18px; border: 0; border-radius: 13px; cursor: pointer;
    background: linear-gradient(135deg, var(--vio2), #5a3a90); color: #fff;
    font: 700 12.5px 'Segoe UI'; letter-spacing: .05em; transition: transform .12s, filter .2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.15); }
.btn.sm { padding: 7px 14px; font-size: 11.5px; }
.palmthumb {
    width: 100%; max-width: 320px; border-radius: 14px; border: 1px solid var(--line2);
    display: block; margin: 6px auto;
}
.dropzone {
    border: 1.5px dashed var(--line2); border-radius: var(--rad); padding: 26px 14px;
    text-align: center; color: var(--dim); font-size: 12.5px; cursor: pointer;
    background: rgba(150,100,220,.06); transition: all .18s; margin-bottom: 8px;
}
.dropzone:hover, .dropzone.over { border-color: var(--vio); background: rgba(150,100,220,.14); color: #fff; }
.dropzone .big { font-size: 30px; display: block; margin-bottom: 6px; }
.scanprog { height: 6px; border-radius: 4px; background: rgba(150,100,220,.12); overflow: hidden; margin: 8px 0; }
.scanprog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--vio2), var(--gold)); transition: width .3s; }

/* ---------------- dock ---------------- */
#dock {
    position: relative; z-index: 30; margin: 0 auto 10px; padding: 8px 10px;
    max-width: min(96vw, 1060px);
    background: rgba(18,12,34,.78); border: 1px solid var(--line); border-radius: 22px;
    backdrop-filter: blur(14px); box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.dock-row { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
#dock button {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    min-width: 44px; padding: 6px 7px 5px; border: 0; border-radius: 12px; cursor: pointer;
    background: transparent; color: var(--dim); transition: all .15s;
}
#dock button .g { font-size: 15px; filter: grayscale(.4) brightness(.9); }
#dock button i { font-style: normal; font: 600 8px 'Segoe UI'; letter-spacing: .08em; text-transform: uppercase; }
#dock button:hover { background: rgba(140,90,200,.16); color: #fff; }
#dock button:hover .g { filter: none; }
#dock button.on { background: linear-gradient(160deg, rgba(160,110,230,.35), rgba(90,55,140,.35)); color: #fff; box-shadow: 0 0 14px rgba(160,110,230,.25); }
#dock button.on .g { filter: none; }

/* ---------------- sheets ---------------- */
#overlay {
    position: fixed; inset: 0; z-index: 50; background: rgba(6,4,14,.55); backdrop-filter: blur(3px);
    display: none; align-items: flex-end; justify-content: center;
}
#overlay.open { display: flex; }
.sheet {
    display: none; width: 100%; max-width: 480px; max-height: 84vh; overflow-y: auto;
    background: linear-gradient(170deg, #1c1230, #120b20); border: 1px solid var(--line2); border-bottom: 0;
    border-radius: 22px 22px 0 0; padding: 16px 18px 30px;
    animation: rise .3s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -12px 60px rgba(140,90,200,.18);
}
.sheet.open { display: block; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; margin-bottom: 10px; color: #f4ecfc; }
.sheet-head .x { margin-left: 0; }
.sheet input, .sheet select {
    width: 100%; background: #140c24; color: var(--ink); border: 1px solid var(--line);
    border-radius: 11px; padding: 10px 12px; font: 14px 'Segoe UI'; margin-bottom: 8px; color-scheme: dark;
}
.sheet input:focus, .sheet select:focus { outline: none; border-color: rgba(190,150,240,.6); }
.sheet-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.sheet-row label { min-width: 64px; font-size: 11.5px; color: var(--dim); letter-spacing: .05em; }
.sheet-row input[type="number"], .sheet-row input[type="file"] { flex: 1; }
.sheet-row input[type="checkbox"] { width: auto; }
.sheet .btn { width: 100%; margin-top: 6px; }
.sheet-sub { font-size: 11px; color: var(--faint); margin-top: 8px; }
.bgsel {
    border: 1px solid var(--line); background: rgba(34,24,58,.55); color: var(--dim);
    font: 600 11px 'Segoe UI'; padding: 8px 12px; border-radius: 11px; cursor: pointer;
}
.bgsel:hover { color: #fff; border-color: var(--line2); }
.bgsel.on { background: linear-gradient(135deg, rgba(160,110,230,.4), rgba(90,55,140,.4)); color: #fff; border-color: var(--line2); }
.emojirow { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.emojirow .icon-btn { margin-left: 0; font-size: 17px; padding: 7px 10px; }
#dtBody p { font-size: 13px; color: var(--dim); margin: 6px 0; }
#dtBody b { color: var(--vio); }

/* ---------------- toast + status ---------------- */
#hint {
    position: fixed; left: 50%; bottom: 118px; transform: translateX(-50%) translateY(8px);
    z-index: 40; background: rgba(26,18,48,.92); border: 1px solid var(--line2); color: var(--ink);
    font: 600 12px 'Segoe UI'; padding: 9px 16px; border-radius: 999px; opacity: 0;
    transition: all .3s; pointer-events: none; max-width: 88vw; text-align: center;
}
#hint.show { opacity: 1; transform: translateX(-50%); }
#statusline {
    position: fixed; left: 14px; bottom: 10px; z-index: 25; font: 600 10.5px 'Segoe UI';
    color: var(--faint); letter-spacing: .05em; pointer-events: none;
}

/* ---------------- brand + wallpaper chrome ---------------- */
#goaBrand { transition: opacity .3s; }
body.wpchrome #topbar, body.wpchrome #chips, body.wpchrome #dock,
body.wpchrome #statusline, body.wpchrome #content, body.wpchrome #hint { display: none !important; }

/* ---------------- responsive ---------------- */
@media (max-width: 640px) {
    #topbar { padding: 8px 10px 4px; }
    #chips { padding: 0 10px 6px; }
    #dock { border-radius: 18px; padding: 6px 6px; margin-bottom: 6px; }
    #dock button { min-width: 38px; padding: 5px 5px 4px; }
    #dock button i { font-size: 7px; }
    .row em { max-width: 45%; }
}
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
