:root {
    color-scheme: light;
    --plum-950: #331d35;
    --plum-850: #4f294f;
    --plum-700: #6f3a68;
    --berry-500: #a84f7a;
    --berry-100: #f5e8f0;
    --berry-050: #fbf7fa;
    --ink: #211b22;
    --muted: #756c76;
    --quiet: #a49aa3;
    --line: #e9e1e7;
    --surface: #ffffff;
    --canvas: #fbfafb;
    --success: #17845c;
    --success-soft: #e6f5ef;
    --danger: #b84756;
    --danger-soft: #fff0f2;
    font-family: Inter, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] { display: none !important; }

html { background: var(--canvas); }

body {
    min-width: 320px;
    min-height: 100vh;
    background: var(--canvas);
    color: var(--ink);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { border: 0; background: none; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.shell {
    position: relative;
    width: min(100%, 580px);
    min-height: 100vh;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) 20px max(44px, env(safe-area-inset-bottom));
}

.page-actions { display: flex; min-height: 34px; justify-content: flex-end; margin-bottom: 10px; }
.history-disclosure { position: relative; z-index: 8; }
.history-disclosure > summary {
    position: relative;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: var(--plum-850);
    cursor: pointer;
    list-style: none;
}
.history-disclosure > summary::-webkit-details-marker { display: none; }
.history-disclosure > summary svg { width: 18px; height: 18px; }
.history-count {
    position: absolute;
    top: 1px;
    right: 0;
    min-width: 14px;
    border-radius: 8px;
    background: var(--berry-500);
    color: white;
    padding: 2px 4px;
    font: 800 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: center;
}
.history-panel {
    position: absolute;
    top: 40px;
    right: 0;
    width: min(340px, calc(100vw - 34px));
    max-height: min(68vh, 560px);
    overflow: auto;
    background: var(--surface);
    box-shadow: 0 12px 36px rgba(51, 29, 53, .14);
    padding: 18px;
}
.history-heading { display: flex; align-items: baseline; justify-content: space-between; }
.history-heading h2 { font-size: 15px; }
.history-heading span { color: var(--berry-500); font: 750 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.history-empty { padding: 28px 0 10px; color: var(--quiet); font-size: 11px; text-align: center; }
.history-list { display: grid; gap: 22px; margin-top: 20px; }
.history-item-heading { display: grid; gap: 5px; }
.history-item strong { color: var(--plum-950); font-size: 11px; line-height: 1.35; }
.history-time { color: var(--quiet); font: 650 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.history-item > p { margin-top: 9px; color: var(--muted); font-size: 10px; line-height: 1.55; white-space: pre-line; }
.history-item > a { display: inline-block; margin-top: 8px; color: var(--berry-500); font-size: 9px; text-decoration: none; }

.topbar {
    display: flex;
    min-height: 40px;
    align-items: center;
    justify-content: space-between;
}

.brand, .login-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--plum-950);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    line-height: 1;
    text-decoration: none;
}

.icon-button, .action-link, .edit-disclosure > summary, .danger-link {
    display: grid;
    place-items: center;
}

.topbar-action {
    color: var(--muted);
    font-size: 10px;
}

svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.batch-indicator {
    display: flex;
    min-width: 82px;
    align-items: center;
    justify-content: flex-end;
    color: var(--quiet);
    gap: 7px;
}

.batch-indicator > svg { width: 14px; height: 14px; }
.batch-indicator[data-running="true"] { color: var(--berry-500); }
.batch-indicator[data-running="true"] > svg { animation: batch-spin 900ms linear infinite; }
.batch-indicator[data-error="true"] { color: var(--danger); }

.batch-track {
    position: relative;
    width: 58px;
    height: 2px;
    overflow: hidden;
    background: var(--line);
}

.batch-track > span {
    position: absolute;
    background: currentColor;
    content: "";
    inset: 0;
    transform: scaleX(1);
    transform-origin: left center;
    transition: transform 180ms ease;
}

@keyframes batch-spin { to { transform: rotate(360deg); } }

h1 {
    color: var(--plum-950);
    font-size: clamp(30px, 8.7vw, 40px);
    font-weight: 760;
    line-height: 1.08;
    letter-spacing: -.048em;
}

.message {
    margin-bottom: 14px;
    color: #116443;
    padding: 0;
    font-size: 12px;
    font-weight: 680;
    line-height: 1.45;
}

.message--error { color: var(--danger); }

.push-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 18px;
    padding: 22px 0 24px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.push-heading h2, .section-heading h1 { font-size: 18px; font-weight: 730; letter-spacing: -.025em; }
.push-status { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.push-actions {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
}

.install-hint {
    grid-column: 1 / -1;
    color: var(--quiet);
    font-size: 10px;
    line-height: 1.45;
}

.install-guide {
    width: min(344px, calc(100vw - 28px));
    max-width: none;
    border: 0;
    border-radius: 18px;
    background: var(--surface);
    color: var(--ink);
    padding: 0;
    box-shadow: 0 24px 70px rgba(36, 21, 37, .24);
}

.install-guide::backdrop {
    background: rgba(38, 25, 38, .34);
    -webkit-backdrop-filter: blur(9px);
    backdrop-filter: blur(9px);
}

.install-guide-sheet { padding: 20px 20px 23px; }
.install-guide-heading { display: flex; align-items: center; justify-content: space-between; }
.install-guide-heading h2 { font-size: 17px; font-weight: 760; letter-spacing: -.025em; }
.install-guide-heading button { display: grid; width: 32px; height: 32px; place-items: center; color: var(--muted); }
.install-guide-heading svg { width: 17px; height: 17px; }

.guide-screen {
    overflow: hidden;
    margin-top: 18px;
    border-radius: 12px;
    background: #f1ecf0;
    box-shadow: inset 0 0 0 1px rgba(79, 41, 79, .05);
}
.guide-preview { position: relative; min-height: 126px; background: #fbfafb; padding: 14px 16px; }
.guide-preview > span { display: inline-block; width: 5px; height: 5px; margin-right: 3px; border-radius: 50%; background: #d9cfd7; }
.guide-preview strong { display: block; margin-top: 29px; color: var(--plum-950); font-size: 12px; letter-spacing: -.02em; }
.guide-preview i { display: block; width: 68%; height: 3px; margin-top: 10px; background: #e4dae2; }
.guide-preview i:last-child { width: 44%; margin-top: 6px; }
.guide-address { overflow: hidden; color: var(--muted); padding: 7px 14px 5px; font: 650 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.guide-toolbar { display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; padding: 5px 43px 10px; color: #827681; }
.guide-toolbar > svg, .guide-share svg { width: 16px; height: 16px; }
.guide-toolbar > svg:last-child { justify-self: end; }
.guide-share { display: grid; width: 34px; height: 34px; place-items: center; justify-self: center; border-radius: 50%; background: var(--berry-500); color: white; box-shadow: 0 5px 14px rgba(168, 79, 122, .28); }

.guide-copy { padding: 18px 2px 0; }
.guide-copy > span { color: var(--berry-500); font: 750 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.guide-copy ol { display: grid; gap: 9px; margin: 14px 0 0 18px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.guide-copy b { color: var(--plum-850); font-weight: 750; }

.primary-button, .add-button {
    min-height: 42px;
    border-radius: 3px;
    background: var(--plum-850);
    color: white;
    font-size: 12px;
    font-weight: 750;
}

.primary-button { width: 100%; margin-top: 15px; }
.primary-button--compact { width: auto; min-height: 36px; margin: 0; padding: 0 15px; }
.primary-button:active, .add-button:active { background: var(--plum-950); }

.soft-button {
    min-height: 36px;
    padding: 0 13px;
    border-radius: 3px;
    background: var(--berry-100);
    color: var(--plum-700);
    font-size: 11px;
    font-weight: 720;
}

button:disabled { cursor: default; opacity: .42; }

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 3px;
}

.icon-button--primary { background: var(--plum-850); color: white; }
.icon-button--soft { background: var(--berry-100); color: var(--plum-700); }
.install-help { background: transparent; color: var(--plum-700); }
.install-help:hover { color: var(--berry-500); }
.icon-button svg { width: 17px; height: 17px; }
.icon-bell-off { display: none; }
.icon-button[data-enabled="true"] .icon-bell { display: none; }
.icon-button[data-enabled="true"] .icon-bell-off { display: block; }

.manage-section { padding-top: 29px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.section-meta { display: flex; align-items: center; gap: 11px; }
.section-count { color: var(--berry-500); font: 750 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.add-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 8px;
}

input[type="text"], input[type="password"], input[type="url"] {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-bottom: 1px solid #d8cdd5;
    border-radius: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    padding: 0 2px;
    font-size: 13px;
    user-select: text;
}

input::placeholder { color: #aca2aa; }
input:focus { border-bottom-color: var(--berry-500); box-shadow: 0 1px 0 rgba(168, 79, 122, .18); }
.add-button { display: grid; min-height: 40px; align-self: end; place-items: center; }
.add-button {
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--plum-850);
}
.add-button:hover { color: var(--berry-500); }
.add-button:active { background: transparent; color: var(--plum-950); }
.add-button svg { width: 20px; height: 20px; }

.watch-list { padding-top: 4px; }

.watch-item {
    --group-color: var(--berry-500);
    --group-wash: rgba(168, 79, 122, .085);
    position: relative;
    display: grid;
    grid-template-columns: 31px minmax(0, 1fr);
    gap: 0 10px;
    padding: 17px 0 20px;
}

.watch-item[data-group] {
    margin-right: -8px;
    margin-left: -11px;
    background: linear-gradient(90deg, var(--group-wash) 0%, rgba(255, 255, 255, 0) 92%);
    padding-right: 8px;
    padding-left: 11px;
}

.watch-item--group-start {
    margin-top: 15px;
    border-radius: 12px 12px 0 0;
    padding-top: 19px;
    padding-bottom: 12px;
}

.watch-item--group-middle {
    padding-top: 12px;
    padding-bottom: 12px;
}

.watch-item--group-end {
    margin-bottom: 17px;
    border-radius: 0 0 12px 12px;
    padding-top: 12px;
    padding-bottom: 19px;
}

.watch-item[data-group]::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background: var(--group-color);
    content: "";
}

.watch-item--group-start::before { top: 14px !important; border-radius: 2px 2px 0 0; }
.watch-item--group-end::before { bottom: 14px !important; border-radius: 0 0 2px 2px; }

.watch-item[data-group="2"], .watch-item[data-group="5"] {
    --group-color: var(--plum-700);
    --group-wash: rgba(111, 58, 104, .075);
}
.watch-item[data-group="3"], .watch-item[data-group="6"] {
    --group-color: #c36b8e;
    --group-wash: rgba(195, 107, 142, .08);
}

.watch-index {
    display: flex;
    grid-row: 1 / span 3;
    align-items: center;
    flex-direction: column;
    gap: 8px;
}

.watch-number {
    padding-top: 1px;
    color: #b8adb5;
    font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
}

.watch-item[data-group] .watch-number { color: var(--group-color); }

.watch-options-toggle {
    display: grid;
    width: 25px;
    height: 25px;
    border: 0;
    background: transparent;
    color: #a99da6;
    padding: 0;
    place-items: center;
}

.watch-options-toggle:hover { color: var(--berry-500); }
.watch-options-toggle svg { width: 15px; height: 15px; transition: transform 160ms ease; }
.watch-options-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.watch-copy { min-width: 0; }

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 7px;
    color: var(--success);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: .03em;
}

.status > span:first-child { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.status[data-status="ERROR"] { color: var(--danger); }
.status[data-status="ERROR"] > span:first-child { background: var(--danger); }

.watch-updated {
    overflow: hidden;
    color: #8b7f87;
    font: 620 8px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.015em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-badge {
    margin-left: auto;
    color: var(--group-color);
    font: 780 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .04em;
}

.watch-url {
    display: block;
    overflow: hidden;
    color: var(--ink);
    font-size: 12px;
    font-weight: 640;
    line-height: 1.4;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-id {
    overflow: hidden;
    margin-top: 5px;
    color: var(--quiet);
    font: 600 8px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watch-actions {
    display: flex;
    grid-column: 2;
    align-items: center;
    margin-top: 8px;
    gap: 4px;
}

.watch-actions form { margin: 0; }
.action-link, .edit-disclosure > summary, .danger-link {
    width: 29px;
    height: 29px;
    border: 0;
    background: none;
    color: var(--muted);
    padding: 0;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
}

.action-link svg, .edit-disclosure > summary svg, .danger-link svg { width: 15px; height: 15px; }
.action-link:hover, .edit-disclosure > summary:hover { color: var(--plum-700); background: var(--berry-050); }
.edit-disclosure > summary::-webkit-details-marker { display: none; }
.danger-link { color: var(--danger); }
.danger-link:hover { background: var(--danger-soft); }

.watch-options {
    grid-column: 2;
    margin-top: 11px;
    color: #584e56;
    font-size: 11px;
    line-height: 1.55;
}

.watch-options ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.watch-options li { position: relative; padding-left: 11px; }
.watch-options li::before {
    position: absolute;
    top: .68em;
    left: 0;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--group-color, var(--berry-500));
    content: "";
}
.watch-options p { margin: 0; color: var(--quiet); }

.edit-panel {
    position: absolute;
    z-index: 3;
    right: 0;
    left: 0;
    margin-top: 9px;
    border-top: 1px solid var(--berry-500);
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
    padding: 13px 0 15px 41px;
}

.edit-panel form { display: grid; gap: 8px; }
.edit-panel label, .stack label { color: #544b54; font-size: 11px; font-weight: 680; }
.edit-panel input[type="url"] { min-height: 40px; font-size: 11px; }
.edit-panel .primary-button { justify-self: start; }

.empty { margin: 34px 0; color: var(--muted); text-align: center; font-size: 12px; }

.key-section { margin-top: 34px; }
.key-disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ink);
    cursor: pointer;
    font-size: 15px;
    font-weight: 720;
    list-style: none;
}
.key-disclosure > summary::-webkit-details-marker { display: none; }
.key-content { padding-top: 18px; }
.key-toolbar { display: flex; min-height: 32px; align-items: center; justify-content: space-between; }
.key-copy-status { color: var(--muted); font-size: 10px; }
.key-list { display: grid; gap: 15px; margin-top: 9px; }
.key-item { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; }
.key-value { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 6px; }
.key-value code { color: var(--plum-950); font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.key-state, .key-bound { font-size: 8px; font-weight: 720; }
.key-state--enabled { color: var(--success); }
.key-state--disabled { color: var(--danger); }
.key-bound { color: var(--quiet); }
.key-actions { display: flex; align-items: center; flex: none; gap: 2px; }
.key-actions form { margin: 0; }
.key-icon { display: grid; width: 29px; height: 29px; place-items: center; color: var(--muted); }
.key-icon:hover { color: var(--plum-700); }
.key-icon--danger { color: var(--danger); }
.key-icon svg { width: 15px; height: 15px; }

.logout-form { margin-top: 36px; text-align: center; }
.logout-form button { color: var(--quiet); font-size: 10px; }

.login-body { background: var(--canvas); }
.shell--login { display: grid; max-width: 410px; align-items: center; }
.login-panel { width: 100%; }
.login-panel h1 { margin: 0 0 28px; font-size: 24px; white-space: nowrap; }
.login-form { width: 100%; }
.login-key-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: end;
    gap: 4px;
}
.login-key-row input { min-height: 44px; }
.login-submit {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    background: transparent;
    color: var(--plum-850);
}
.login-submit:hover { color: var(--berry-500); }
.login-submit:active { color: var(--plum-950); }
.login-submit svg { width: 20px; height: 20px; }
.stack { display: grid; gap: 8px; }
.stack label { margin-top: 9px; color: var(--muted); font-size: 10px; letter-spacing: .04em; }
.stack input { min-height: 42px; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid rgba(168, 79, 122, .35); outline-offset: 3px; }

@media (max-width: 420px) {
    .shell { padding-right: 17px; padding-left: 17px; }
    .push-section { gap: 9px 12px; }
    .push-actions { gap: 4px; }
    .watch-item { grid-template-columns: 27px minmax(0, 1fr); gap: 0 8px; }
    .watch-actions { gap: 3px; }
    .edit-panel { padding-left: 35px; }
}

@media (min-width: 680px) {
    .shell { padding-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
