/* ============================================================
   PocketWatch — styles (Phase 3). Dark WRS theme.
   Owner notes white, viewer notes cyan (D10). Red = overdue only (D7).
   No CDN, no web fonts (system stack).
   ============================================================ */
:root {
    --bg: #05050d;
    --card: rgba(16, 18, 34, .78);
    --card-2: rgba(22, 24, 44, .85);
    --line: rgba(160, 120, 255, .22);
    --line-2: rgba(255, 255, 255, .09);
    --text: #f3f1ff;
    --muted: #a39dc0;
    --violet: #9b5cff;
    --cyan: #35e4ff;
    --rose: #ff4fd8;
    --green: #60ffb0;
    --red: #ff5c7c;
    --radius: 14px;
    --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; display: flex; flex-direction: column;
    font: 14px/1.5 var(--font); color: var(--text);
    background:
        radial-gradient(circle at 12% 30%, rgba(155, 92, 255, .14), transparent 35%),
        radial-gradient(circle at 85% 70%, rgba(53, 228, 255, .08), transparent 35%),
        linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px) 0 0 / 44px 44px,
        var(--bg);
}
a { color: var(--cyan); }
h1, h2 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }
.pw-skip { position: absolute; left: -9999px; }
.pw-skip:focus { left: 12px; top: 12px; z-index: 99; background: #000; color: var(--cyan); padding: 10px 14px; border-radius: 8px; outline: 2px solid var(--cyan); }
.pw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
.pw-main:focus { outline: none; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
.pw-muted { color: var(--muted); }
.pw-i { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.pw-i-more, .pw-i-grip { stroke-width: 3.2; }
.pw-small { font-size: 12px; }
/* P5: one strong focus ring everywhere (cyan 12:1 on the dark theme). */
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(5,5,13,.9); }

/* ---- Header (full banner on home/login, slim on inner pages) ---- */
.pw-header {
    position: relative; border-bottom: 1px solid rgba(53, 228, 255, .35);
    background: #05050d url('/tools/img/PW_banner_sm.webp') right top / auto 220% no-repeat;
    box-shadow: 0 1px 24px rgba(53, 228, 255, .15);
}
.pw-header::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(5,5,13,.92) 30%, rgba(5,5,13,.25) 70%, rgba(5,5,13,.55)); }
.pw-hero { background-image: url('/tools/img/PW_banner.webp'); background-size: cover; background-position: right 35%; }
.pw-hero::before { background: linear-gradient(90deg, rgba(5,5,13,.85) 25%, rgba(5,5,13,.1) 65%); }
.pw-header-inner {
    position: relative; max-width: 1440px; margin: 0 auto; padding: 10px 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.pw-hero .pw-header-inner { padding: 22px 24px 26px; min-height: 190px; }
.pw-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
.pw-logo { width: 64px; height: 64px; filter: drop-shadow(0 0 12px rgba(53,228,255,.35)); }
.pw-hero .pw-logo { width: 140px; height: 140px; }
.pw-wordmark { display: flex; flex-direction: column; }
.pw-word { font-size: 30px; font-weight: 800; letter-spacing: .01em; }
.pw-hero .pw-word { font-size: 46px; }
.pw-w1 { color: #fff; }
.pw-w2 { color: var(--cyan); text-shadow: 0 0 14px rgba(53,228,255,.5); }
.pw-tag { font-size: 10px; letter-spacing: .32em; text-transform: uppercase; color: #d9d4f5; }
.pw-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pw-nav .pw-btn { background: rgba(5,5,13,.78); border-color: rgba(255,255,255,.16); backdrop-filter: blur(6px); }
.pw-nav .pw-btn:hover { border-color: rgba(53,228,255,.55); }
.pw-nav .pw-btn.pw-on { background: rgba(5,5,13,.82); border-color: rgba(53,228,255,.7); }
.pw-hero .pw-nav { align-self: flex-start; }
.pw-inline-form { display: inline; margin: 0; }

/* ---- Buttons & fields ---- */
.pw-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.04); color: var(--text); font: inherit; font-size: 13px;
    text-decoration: none; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, transform .1s;
}
.pw-btn:hover { border-color: rgba(53,228,255,.5); background: rgba(53,228,255,.07); }
.pw-btn:active { transform: translateY(1px); }
.pw-btn:disabled { opacity: .45; cursor: not-allowed; }
.pw-btn.pw-sm { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.pw-btn.pw-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 7px; min-height: 24px; min-width: 24px; }
.pw-btn.pw-block { width: 100%; }
.pw-primary { border-color: rgba(53,228,255,.6); background: linear-gradient(135deg, rgba(53,228,255,.2), rgba(155,92,255,.22)); box-shadow: 0 0 14px rgba(53,228,255,.18); }
.pw-violet { border-color: rgba(155,92,255,.7); background: rgba(155,92,255,.35); }
.pw-violet-o { border-color: rgba(155,92,255,.6); }
.pw-teal { border-color: rgba(53,228,255,.6); color: var(--cyan); }
.pw-success { border-color: rgba(96,255,176,.45); color: var(--green); }
.pw-danger { border-color: rgba(255,92,124,.45); color: #ff9ab0; }
.pw-danger:hover { border-color: var(--red); background: rgba(255,92,124,.1); }
.pw-ghost { border-color: transparent; background: transparent; }
.pw-ghost.pw-on { border-color: rgba(53,228,255,.65); color: var(--cyan); box-shadow: 0 0 12px rgba(53,228,255,.25); }
.pw-row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.pw-f { display: flex; flex-direction: column; gap: 5px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pw-f-grow { flex: 1 1 260px; }
.pw-f-full { flex: 1 1 100%; }
input, select, textarea {
    font: inherit; font-size: 13.5px; color: var(--text); text-transform: none; letter-spacing: 0;
    background: rgba(0,0,0,.35); border: 1px solid #7a759c; border-radius: 9px; padding: 8px 10px; width: 100%;
}
/* Field borders ≥3:1 against the cards (WCAG 1.4.11). */
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
::placeholder { color: #8d88ad; opacity: 1; }
input[type=date] { color-scheme: dark; width: auto; }
select { color-scheme: dark; }
textarea { resize: vertical; min-height: 42px; }

/* ---- Layout ---- */
.pw-main { flex: 1; }
.pw-wrap { max-width: 1440px; margin: 0 auto; padding: 22px 24px 40px; }
.pw-narrow { max-width: 560px; }
.pw-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: 0 18px 50px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
    backdrop-filter: blur(6px);
}
.pw-flash { border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 13px; }
.pw-flash-ok { background: rgba(96,255,176,.08); border: 1px solid rgba(96,255,176,.35); color: var(--green); }
.pw-flash-err { background: rgba(255,92,124,.08); border: 1px solid rgba(255,92,124,.4); color: #ff9ab0; }

/* ---- Login / account ---- */
.pw-login-wrap { display: flex; justify-content: center; padding: 40px 16px; }
.pw-login, .pw-account { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }

/* ---- Home ---- */
.pw-home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pw-home-head h1 { font-size: 26px; }
.pw-new-list { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.pw-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.pw-list-card { display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s; }
.pw-list-card:hover { border-color: rgba(53,228,255,.45); transform: translateY(-2px); }
.pw-card-overdue { border-color: rgba(255,92,124,.45); }
.pw-lc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pw-lc-title { font-size: 17px; }
.pw-lc-title a { color: var(--text); text-decoration: none; }
.pw-lc-title a:hover { color: var(--cyan); }
.pw-lc-desc { margin: 0; color: var(--muted); font-size: 13px; }
.pw-lc-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 12.5px; }
.pw-badge { flex: none; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: #05050d; background: var(--cyan); box-shadow: 0 0 10px rgba(53,228,255,.5); }
.pw-overdue-chip { font-size: 11.5px; color: #ff9ab0; border: 1px solid rgba(255,92,124,.4); border-radius: 999px; padding: 1px 8px; }
.pw-empty-card { text-align: center; color: var(--muted); }

/* ---- Progress ---- */
.pw-progress { display: inline-flex; align-items: center; gap: 10px; font-size: 12.5px; color: #d8d3f2; }
.pw-bar { position: relative; width: 130px; height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
.pw-bar-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), #7ff3ff); box-shadow: 0 0 10px rgba(53,228,255,.6); transition: width .35s; }
.pw-lc-prog .pw-bar { flex: 1; width: auto; }

/* ---- Due dates (red = overdue only) ---- */
.pw-due { font-size: 12.5px; color: #cfc9ea; white-space: nowrap; }
.pw-due strong { color: var(--cyan); }
.pw-overdue, .pw-overdue strong { color: var(--red); }

/* ---- List page ---- */
.pw-cols { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.pw-col-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pw-col-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 14px; }
.pw-tabs { display: none; }

.pw-list-head { display: grid; grid-template-columns: auto 1fr; gap: 16px 18px; align-items: start; }
.pw-lh-icon { width: 92px; height: 92px; border-radius: 14px; display: grid; place-items: center; font-size: 46px; color: #c9b5ff;
    border: 1px solid rgba(155,92,255,.5); background: linear-gradient(135deg, rgba(155,92,255,.18), rgba(53,228,255,.08)); box-shadow: 0 0 22px rgba(155,92,255,.25); }
.pw-lh-title { font-size: 28px; }
.pw-lh-desc { margin: 6px 0 0; color: #d0cbe8; }
.pw-lh-meta { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.pw-lh-btns { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: -4px; }
.pw-list-edit { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; border-top: 1px solid var(--line-2); padding-top: 14px; }

.pw-sections { display: flex; flex-direction: column; gap: 14px; }
.pw-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 14px 40px rgba(0,0,0,.4); }
.pw-sec-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.pw-sec-title { font-size: 19px; margin-right: 6px; }
.pw-sec-acts { display: inline-flex; gap: 6px; }
.pw-sec-head .pw-progress { margin-left: auto; }
.pw-collapse { background: none; border: 0; color: var(--text); font-size: 18px; cursor: pointer; padding: 2px 2px; transition: transform .15s; display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; border-radius: 6px; }
.pw-section.pw-collapsed .pw-collapse { transform: rotate(-90deg); }
.pw-section.pw-collapsed .pw-sec-body { display: none; }
.pw-section.pw-collapsed .pw-sec-head { border-bottom: 0; }
.pw-sec-rename { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.pw-sec-body { padding: 4px 8px 10px; }
.pw-unsectioned .pw-sec-title { color: #cbc6e6; }

.pw-items { list-style: none; margin: 0; padding: 0; min-height: 8px; }
.pw-item { border-bottom: 1px solid var(--line-2); border-radius: 10px; }
.pw-item:last-child { border-bottom: 0; }
.pw-item.pw-open { background: rgba(155,92,255,.07); outline: 1px solid rgba(155,92,255,.35); }
.pw-item-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; min-height: 42px; }
.pw-handle { flex: none; background: none; border: 0; color: #8f89b3; cursor: grab; font-size: 15px; padding: 4px 2px; touch-action: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; min-width: 24px; min-height: 24px; }
.pw-handle:hover { color: var(--cyan); }
.pw-check { position: relative; flex: none; width: 24px; height: 24px; cursor: pointer; }
.pw-check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 24px; height: 24px; }
.pw-box { position: absolute; inset: 2px; border: 1.5px solid #8f89b3; border-radius: 5px; }
.pw-check input:checked + .pw-box { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 10px rgba(53,228,255,.6); }
.pw-check input:checked + .pw-box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #05050d; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.pw-check input:focus-visible + .pw-box { outline: 2px solid var(--cyan); outline-offset: 2px; }
.pw-item-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.pw-item-meta { display: inline-flex; align-items: center; gap: 12px; flex: none; }
.pw-done .pw-item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(255,255,255,.45); }
.pw-notes-toggle { flex: none; background: none; border: 0; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; padding: 3px 6px; border-radius: 7px; min-height: 24px; }
.pw-notes-toggle.pw-has { color: var(--cyan); }
.pw-notes-toggle:hover { color: var(--cyan); background: rgba(53,228,255,.07); }
.pw-row-acts { display: inline-flex; gap: 6px; flex: none; }
.pw-menu { position: relative; flex: none; display: none; }
.pw-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px; padding: 6px;
    background: #10112a; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.6); display: flex; flex-direction: column; }
.pw-menu-list button { background: none; border: 0; color: var(--text); font: inherit; font-size: 13px; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.pw-menu-list button:hover, .pw-menu-list button:focus-visible { background: rgba(53,228,255,.1); }
.pw-menu-list .pw-danger { color: #ff9ab0; }

/* Hover-reveal row actions on devices that can hover; ⋯ menu elsewhere. */
@media (hover: hover) and (pointer: fine) {
    .pw-row-acts { opacity: 0; transition: opacity .12s; }
    .pw-item-row:hover .pw-row-acts, .pw-item-row:focus-within .pw-row-acts, .pw-open > .pw-item-row .pw-row-acts { opacity: 1; }
    .pw-menu { display: block; }
    .pw-menu .pw-menu-btn { opacity: .7; }
    .pw-item-row:hover .pw-menu-btn, .pw-menu-btn:focus-visible, .pw-menu-btn[aria-expanded=true] { opacity: 1; }
    .pw-kb { opacity: .75; }
    .pw-kb:hover, .pw-kb:focus-visible { opacity: 1; }
}
@media not ((hover: hover) and (pointer: fine)) {
    .pw-row-acts { display: none; }
    .pw-menu { display: block; }
}

.pw-item-edit { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 6px 10px 12px 44px; }
.pw-notes { padding: 4px 12px 12px 44px; }
.pw-note-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pw-note { padding: 8px 12px; border-left: 3px solid; border-radius: 4px 8px 8px 4px; background: rgba(0,0,0,.22); }
.pw-note-owner { border-color: var(--violet); }
.pw-note-owner .pw-note-who, .pw-note-owner .pw-note-body { color: #fff; }
.pw-note-viewer { border-color: var(--cyan); }
.pw-note-viewer .pw-note-who, .pw-note-viewer .pw-note-body { color: var(--cyan); }
.pw-note-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.pw-note-who { font-weight: 700; font-size: 13px; }
.pw-note-when { color: var(--muted); }
.pw-note-acts { margin-left: auto; display: inline-flex; gap: 6px; }
.pw-note-body { margin-top: 3px; white-space: normal; overflow-wrap: anywhere; }
.pw-note-edit { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.pw-note-add { display: flex; gap: 8px; align-items: flex-start; }

.pw-add-item { display: flex; gap: 8px; padding: 8px 8px 2px; position: relative; align-items: center; }
.pw-add-ico { position: absolute; left: 20px; top: 50%; margin-top: 3px; transform: translateY(-50%); color: var(--muted); display: inline-flex; pointer-events: none; }
.pw-add-item input[name=title] { padding-left: 32px; }
.pw-add-item input[name=title] { flex: 1; }
.pw-add-section { display: flex; gap: 10px; }
.pw-add-section input { max-width: 340px; }

/* Drag state */
.pw-dragging { opacity: .9; box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 0 1px var(--cyan); background: #14152e; position: relative; z-index: 30; }
.pw-placeholder { border: 1px dashed rgba(53,228,255,.6); border-radius: 10px; background: rgba(53,228,255,.05); list-style: none; }
body.pw-is-dragging, body.pw-is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---- Sidebar ---- */
.pw-col-side h2 { font-size: 20px; display: flex; align-items: center; gap: 8px; }
.pw-col-side h2 .pw-i { color: var(--cyan); }
.pw-soon { opacity: .75; }
.pw-share p { margin: 6px 0 14px; font-size: 13px; }
.pw-soon-tag { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--violet);
    border: 1px solid rgba(155,92,255,.5); border-radius: 999px; padding: 2px 8px; vertical-align: middle; margin-left: 6px; }
.pw-activity-card p.pw-muted { margin: 4px 0 10px; }
.pw-activity { list-style: none; margin: 0; padding: 0 0 0 4px; }
/* P9 fix: the focusable region (#pw-activity, tabindex=0) is the one that scrolls, so keyboard users can scroll it. */
#pw-activity { max-height: 560px; overflow: auto; }
.pw-activity li { position: relative; display: flex; flex-wrap: wrap; gap: 2px 8px; padding: 0 0 12px 20px; font-size: 13px; }
.pw-activity li::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: -2px; width: 1px; background: rgba(155,92,255,.35); }
.pw-activity li:last-child::before { display: none; }
.pw-act-dot { position: absolute; left: 0; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 8px rgba(155,92,255,.8); }
.pw-act-viewer .pw-act-dot { background: var(--cyan); box-shadow: 0 0 8px rgba(53,228,255,.8); }
.pw-act-viewer strong { color: var(--cyan); }
.pw-act-when { color: var(--muted); font-size: 12px; }
.pw-empty { margin: 0; }

/* ---- Share links (P4) ---- */
.pw-links { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.pw-link { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(0,0,0,.2); }
.pw-link-head { display: flex; align-items: center; gap: 8px; margin: 0; font-size: inherit; font-weight: normal; }
.pw-link-head .pw-i { color: var(--violet); }
.pw-link-label { font-size: 15px; overflow-wrap: anywhere; }
.pw-link-badge { margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; border: 1px solid; }
.pw-lb-active  { color: var(--green); border-color: rgba(96,255,176,.45); }
.pw-lb-expired { color: var(--muted); border-color: rgba(255,255,255,.2); }
.pw-lb-revoked { color: #ff9ab0; border-color: rgba(255,92,124,.45); }
.pw-link-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 4px 0 10px 26px; font-size: 12px; color: var(--muted); }
.pw-sep { opacity: .5; }
.pw-link-btns { display: flex; flex-wrap: wrap; gap: 6px; }
/* Revoked/expired: dashed + muted border instead of fading the text (keeps 4.5:1). */
.pw-link-revoked, .pw-link-expired { border-style: dashed; border-color: rgba(255,255,255,.18); background: transparent; }
.pw-link-revoked .pw-link-label, .pw-link-expired .pw-link-label { color: var(--muted); }
.pw-link-revoked .pw-link-meta, .pw-link-expired .pw-link-meta { margin-bottom: 0; }
.pw-link-expired .pw-link-btns { margin-top: 8px; }
.pw-link-edit, .pw-link-new { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.pw-link-new { padding: 12px 14px; border: 1px dashed rgba(155,92,255,.5); border-radius: 12px; margin-bottom: 12px; }
.pw-secret { border: 1px solid rgba(96,255,176,.5); background: rgba(96,255,176,.06); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
    display: flex; flex-direction: column; gap: 10px; box-shadow: 0 0 18px rgba(96,255,176,.12); }
.pw-secret-head { display: flex; align-items: center; gap: 8px; color: var(--green); }
.pw-secret-x { margin-left: auto; }
.pw-secret input { font-size: 13px; }
.pw-warn { margin: 0; color: #ffd166; }
.pw-mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; font-size: 15px !important; }
.pw-offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ---- Share page (viewer, P4) ---- */
.pw-share-page { max-width: 1040px; }
.pw-share-page .pw-col-main { gap: 14px; }
.pw-share-hint { grid-column: 1 / -1; margin: -6px 0 0; }
.pw-cyan { color: var(--cyan); }
.pw-viewing { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 8px 12px; border-radius: 10px;
    background: rgba(5,5,13,.78); border: 1px solid rgba(53,228,255,.35); color: #d9f7ff; }
.pw-viewing strong { color: var(--cyan); }

/* ---- Clone & templates (P6) ---- */
.pw-tpl-chip { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #d3bcff;
    border: 1px solid rgba(155,92,255,.6); background: rgba(155,92,255,.15); border-radius: 999px; padding: 2px 9px; vertical-align: middle; }
.pw-tpl-back { font-size: 12.5px; color: var(--muted); text-decoration: none; margin-right: 6px; }
.pw-tpl-back:hover { color: var(--cyan); }
.pw-is-template .pw-list-head { border-color: rgba(155,92,255,.5); box-shadow: 0 0 24px rgba(155,92,255,.15), 0 18px 50px rgba(0,0,0,.45); }
.pw-tpl-day, .pw-tpl-day strong { color: #c9b5ff; }
.pw-tpl-dot { flex: none; width: 24px; height: 24px; display: inline-grid; place-items: center; }
.pw-tpl-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: rgba(155,92,255,.8); }
.pw-tpl-count .pw-prog-txt { color: var(--muted); }
.pw-day-in { width: 96px !important; flex: none; }
.pw-copy-form { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; border-top: 1px solid var(--line-2); padding-top: 14px; }
.pw-copy-title { font-size: 15px; margin: 0; }
.pw-check-row { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.pw-check-row { min-height: 24px; }
.pw-check-row input { width: 18px; height: 18px; accent-color: var(--cyan); }
.pw-use-tpl .pw-copy-form { flex-direction: column; align-items: stretch; border-top: 0; padding-top: 4px; margin-bottom: 10px; }
.pw-use-tpl h2 .pw-i { color: var(--violet); }
.pw-tpl-card { border-color: rgba(155,92,255,.35); }
.pw-tpl-use-wrap > summary { list-style: none; cursor: pointer; display: inline-flex; }
.pw-tpl-use-wrap > summary::-webkit-details-marker { display: none; }
.pw-tpl-use-wrap .pw-copy-form { flex-direction: column; align-items: stretch; margin-top: 10px; padding: 12px; border: 1px dashed rgba(155,92,255,.5); border-radius: 10px; }
.pw-tpl-intro { margin: -6px 0 16px; }

/* ---- Toast ---- */
.pw-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; max-width: min(92vw, 520px);
    padding: 10px 16px; border-radius: 10px; font-size: 13px; background: #1a1030; border: 1px solid rgba(255,92,124,.55); color: #ffc2cf;
    box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.pw-toast.pw-toast-ok { border-color: rgba(96,255,176,.5); color: var(--green); }

/* ---- Footer ---- */
.pw-footer { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 18px 28px 22px; color: #d8d3f2; font-size: 13.5px;
    border-top: 1px solid var(--line-2); max-width: 1440px; width: 100%; margin: 0 auto; }
.pw-footer img { width: 36px; height: 36px; opacity: .9; padding-right: 12px; border-right: 1px solid rgba(255,255,255,.25); box-sizing: content-box; }

/* ---- Responsive ---- */
@media (max-width: 1080px) {
    .pw-cols { grid-template-columns: 1fr; }
    .pw-col-side { position: static; }
    .pw-tabs { display: flex; gap: 6px; }
    .pw-tab { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; cursor: pointer; }
    .pw-tab.pw-on { color: var(--cyan); border-color: rgba(53,228,255,.6); }
    .pw-col-side [data-pane].pw-pane-off { display: none; }
}
@media (max-width: 720px) {
    .pw-wrap { padding: 14px 12px 30px; }
    .pw-header-inner { padding: 8px 12px; }
    .pw-hero .pw-header-inner { min-height: 0; padding: 16px 12px; }
    .pw-hero .pw-logo { width: 84px; height: 84px; }
    .pw-hero .pw-word { font-size: 32px; }
    .pw-logo { width: 46px; height: 46px; }
    .pw-word { font-size: 22px; }
    .pw-tag { letter-spacing: .18em; }
    .pw-nav { width: 100%; justify-content: flex-end; }
    .pw-list-head { grid-template-columns: 1fr; }
    .pw-lh-icon { display: none; }
    .pw-lh-title { font-size: 22px; }
    .pw-lh-btns { justify-content: flex-start; }
    .pw-sec-head .pw-progress { margin-left: 0; width: 100%; }
    .pw-sec-head .pw-bar { flex: 1; }
    .pw-item-row { display: grid; grid-template-columns: 24px 24px minmax(0, 1fr) 34px; column-gap: 8px; row-gap: 2px; align-items: center; }
    .pw-add-ico { display: none; }
    .pw-item-row .pw-row-acts { display: none; }
    .pw-item-row .pw-menu { display: block; }
    .pw-item-row .pw-menu-btn { opacity: 1; }
    .pw-add-item input[name=title] { padding-left: 10px; }
    .pw-item-row .pw-handle { grid-column: 1; grid-row: 1; }
    .pw-item-row .pw-check  { grid-column: 2; grid-row: 1; }
    .pw-item-row .pw-item-title { grid-column: 3; grid-row: 1; }
    .pw-item-row .pw-menu   { grid-column: 4; grid-row: 1; }
    .pw-item-meta { grid-column: 3 / 5; grid-row: 2; gap: 10px; flex-wrap: wrap; }
    .pw-sec-acts { flex-wrap: wrap; }
    .pw-lh-meta { gap: 10px; }
    .pw-item-edit, .pw-notes { padding-left: 10px; }
    .pw-add-item { flex-wrap: wrap; }
    .pw-add-item input[name=title] { flex-basis: 100%; }
    .pw-add-section input { max-width: none; }
    .pw-footer { justify-content: center; text-align: center; }
    /* Share page has no drag handle or menu: two columns. */
    .pw-share-page .pw-item-row { grid-template-columns: 24px minmax(0, 1fr); }
    .pw-share-page .pw-item-row .pw-check { grid-column: 1; }
    .pw-share-page .pw-item-row .pw-item-title { grid-column: 2; }
    .pw-share-page .pw-item-meta { grid-column: 2; }
    .pw-share-page .pw-notes { padding-left: 8px; }
}
/* Very narrow screens / 400% zoom (WCAG 1.4.10 reflow at 320px). */
@media (max-width: 380px) {
    .pw-hero .pw-logo { width: 64px; height: 64px; }
    .pw-hero .pw-word, .pw-word { font-size: 24px; }
    .pw-tag { letter-spacing: .1em; font-size: 9.5px; }
    .pw-brand { gap: 10px; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
    .pw-list-card:hover, .pw-btn:active { transform: none; }
}
/* Windows High Contrast / forced colors: keep focus and checkbox state visible. */
@media (forced-colors: active) {
    :focus-visible { outline: 2px solid CanvasText; }
    .pw-box { border-color: CanvasText; }
    .pw-check input:checked + .pw-box { background: Highlight; }
    .pw-bar { border: 1px solid CanvasText; }
}

/* ---- P7: AI access (Account page) ---- */
.pw-ai { margin-top: 18px; }
.pw-ai h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.pw-ai h3 { margin: 0; font-size: 14px; }
.pw-ai code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--cyan); overflow-wrap: anywhere; }
.pw-tokens { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pw-token { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(0,0,0,.2); }
.pw-token-expired { border-style: dashed; }
.pw-token-head { display: flex; align-items: center; gap: 8px; }
.pw-token p { margin: 4px 0 8px; overflow-wrap: anywhere; }
.pw-token-new { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line-2); padding-top: 14px; margin-top: 6px; }
.pw-token-new p { margin: 0; }
.pw-check-row { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.pw-check-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--cyan); }
.pw-act-ai .pw-act-dot { background: var(--violet); }
.pw-account.pw-ai { max-width: none; }

/* ---- P8: open share links ---- */
.pw-lb-open { margin-left: auto; color: #c9a7ff; border-color: rgba(201,167,255,.55); }   /* P10: violet — gold is reserved for "yours" (D93) */
.pw-lb-open + .pw-link-badge { margin-left: 0; }
.pw-link-new .pw-check-row { font-size: 13px; }
.pw-link-new p { margin: 0; }

/* ---- P9: link permissions (D87–D89) ---- */
.pw-link-head { flex-wrap: wrap; }
.pw-link-badge + .pw-link-badge { margin-left: 0; }
.pw-lb-perm { color: var(--text); border-color: rgba(255,255,255,.35); }
.pw-link-new select, .pw-link-edit select { min-height: 32px; }
/* View-only link: checkbox state shown, no control. */
.pw-check-ro { cursor: default; }
.pw-done .pw-check-ro .pw-box { background: var(--cyan); border-color: var(--cyan); }
.pw-done .pw-check-ro .pw-box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #05050d; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
@media (forced-colors: active) {
    .pw-done .pw-check-ro .pw-box { background: CanvasText; }
}

/* ---- P10: item assignment (D93–D96) ---- */
:root { --gold: #ffc94d; }
.pw-assign { display: inline-flex; align-items: center; font-size: 11.5px; line-height: 1.4; padding: 1px 8px; border-radius: 999px;
    color: #d4d0e6; border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.04); white-space: nowrap;
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.pw-assign-mine { color: #1a1300; background: var(--gold); border-color: var(--gold); font-weight: 600; }
.pw-item.pw-mine { box-shadow: inset 3px 0 0 var(--gold); }
.pw-item.pw-mine > .pw-item-row { padding-left: 11px; }
.pw-add-item .pw-assign-in { flex: none; max-width: 150px; }
.pw-filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.pw-f.pw-f-inline { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.pw-f-inline select { min-height: 32px; }
.pw-mine-toggle[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.pw-mine-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.pw-item[hidden], .pw-section[hidden] { display: none !important; }
@media (max-width: 720px) {
    .pw-add-item .pw-assign-in { max-width: none; flex: 1 1 40%; }
    .pw-assign { max-width: 140px; }
}
@media (forced-colors: active) {
    .pw-assign { border: 1px solid CanvasText; }
    .pw-assign-mine { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
    .pw-item.pw-mine { box-shadow: none; border-left: 3px solid Highlight; }
    .pw-mine-dot { forced-color-adjust: none; background: Highlight; }
}

/* ---- P11: per-owner branding (D104) — colours come from brand.php?css= ---- */
.pw-brand-owner { display: flex; align-items: center; gap: 14px; min-width: 0; color: var(--text); }
.pw-brand-logo { display: block; height: 48px; width: auto; max-width: 320px; object-fit: contain; }
.pw-brand-name { font-size: 24px; font-weight: 800; letter-spacing: .01em; overflow-wrap: anywhere; }
.pw-brand-preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin: 10px 0;
    border: 1px solid var(--line); border-radius: 12px; background: rgba(5,5,13,.6); }
.pw-brand-preview .pw-brand-name { font-size: 20px; }
.pw-brand-swatch { display: inline-block; width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(255,255,255,.35); margin-left: auto; }
@media (max-width: 720px) {
    .pw-brand-logo { height: 36px; max-width: 180px; }
    .pw-brand-name { font-size: 19px; }
}
@media (forced-colors: active) {
    .pw-brand-swatch { forced-color-adjust: none; }
}
