/* plum-portal — find a Plum Box
 *
 * Plum Design System "console register" re-skin (design_handoff_portal_refresh):
 *   paper/ink neutrals, Pretendard Variable, hairline borders; the focus trace is
 *   ink (2026-11-02 — it was a wine accent). Below the card, one quiet line is the trust signal since v3:
 *   plumbox.me never asks for a password (the old sealed-envelope indicator said
 *   the email never left the browser, which is no longer what happens).
 * Values are exact per the handoff prototype — treat them as pinned.
 */

@font-face {
    font-family: 'Pretendard Variable';
    src: url('/static/fonts/PretendardVariable.woff2') format('woff2-variations');
    font-weight: 45 920;
    font-style: normal;
    font-display: swap;
}

:root {
    --paper: #FCFCFC;
    --surface: #FFFFFF;
    --ink: #101012;
    --muted: #6E6E76;
    --line: #ECECEE;
    --line-strong: #DEDEE1;
    --error: #A83A3A;
    --live: #2E7D5B;

    /* Focus (2026-11-02, CEO pick "A"): ink, no colour. A field in use gets an ink
       border (--field-focus); a button or row reached by keyboard gets an ink ring
       set off by a gap of the surface colour, so it shows on the ink button too. */
    --field-focus: 0 0 0 1px var(--ink);
    --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
    --shadow-card: 0 1px 2px rgba(16, 16, 18, 0.04), 0 8px 24px rgba(16, 16, 18, 0.06);
    --shadow-soft: 0 1px 3px rgba(16, 16, 18, 0.08);

    --font-stack: 'Pretendard Variable', -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #0A0A0B;
        --surface: #151517;
        --ink: #F4F4F5;
        --muted: #97979F;
        --line: #26262A;
        --line-strong: #34343A;
        --error: #DE8686;
        --live: #5FBE92;
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

/* The stage flow toggles the hidden attribute; author display rules
   (e.g. form.stage { display: flex }) would otherwise override the UA's
   [hidden] { display: none } and show every stage at once. */
[hidden] {
    display: none !important;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-stack);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

/* Card + trust line stack. */
.auth-column {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
    padding: 44px 40px 32px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
    color: var(--ink);
}

.auth-logo .logo-icon,
.auth-logo .logo-icon img {
    display: block;
    margin: 0 auto 14px;
}

.auth-logo .logo-icon img {
    margin: 0 auto;
}

/* A box: the product's top view in a grey rounded tile, as the apps' PlumBoxThumbTile
   (corner 30 % of the tile, the picture 80 % of its height). */
.box-thumb,
.box-row-icon.box-thumb,
.chip-icon.box-thumb {
    background: var(--line);
    border: 0;
    border-radius: 30%;
}

.box-thumb img {
    display: block;
}

.auth-logo h1 {
    margin: 0;
    font-size: 21px;
    font-weight: 680;
    letter-spacing: -0.018em;
    color: var(--ink);
}

/* ─── Stages ─────────────────────────────────────────────────────── */

/* Entrance plays each time a stage is shown (display:none → block
   restarts the CSS animation). */
.stage {
    animation: plum-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

form.stage,
.stage-form,
.stage.link-stage,
#portal-go {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* A plain sentence between the chip and the field ("메일을 보냈어요 …"). */
.stage-note {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
    overflow-wrap: anywhere;
}

@keyframes plum-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field-label {
    font-size: 12px;
    font-weight: 620;
    color: var(--muted);
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="email"] {
    width: 100%;
    padding: 13px 14px;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus {
    border-color: var(--ink);
    box-shadow: var(--field-focus);
}

input::placeholder {
    color: var(--muted);
}

/* The mailed code: digits, spaced like the mail shows them. */
/* The mailed code: six boxes (2026-11-02, CEO pick "A"). One real input lies over
   them, its own text invisible, so typing, pasting "123 456" and the phone's
   one-time-code autofill all go to one field; app.js draws its digits into the boxes. */
.otp {
    position: relative;
}

.otp-boxes {
    display: flex;
    gap: 8px;
}

.otp-d {
    flex: 1;
    min-width: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font-size: 22px;
    font-weight: 640;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.otp-d.cur {
    border-color: var(--ink);
    box-shadow: var(--field-focus);
}

.otp-d.cur:empty::after {
    content: "";
    width: 1.5px;
    height: 22px;
    background: var(--ink);
    animation: otp-caret 1s steps(1) infinite;
}

@keyframes otp-caret {
    50% { opacity: 0; }
}

input.code-input,
input.code-input:focus {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: transparent;
    caret-color: transparent;
    font-size: 16px;
    letter-spacing: 0;
}

input.code-input::selection {
    background: transparent;
}

.btn-primary {
    width: 100%;
    padding: 13px 16px;
    border-radius: 9px;
    border: none;
    background: var(--ink);
    color: var(--surface);
    font-family: inherit;
    font-size: 15px;
    font-weight: 620;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.75;
    cursor: progress;
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* Inline field error — sits between the input and the button. */
.field-error {
    margin: 0;
    font-size: 12.5px;
    color: var(--error);
    text-align: left;
}

/* A neutral line after something worked ("새 코드를 보냈어요."). */
.field-info {
    margin: 0;
    font-size: 12.5px;
    color: var(--live);
    text-align: left;
}

/* Under the list (after [맞아요] / [아니에요]) and its error: a little air. */
#box-info,
#box-error {
    margin-top: 12px;
}

.btn-link {
    background: none;
    border: 0;
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    margin-top: 14px;
    padding: 8px;
    width: 100%;
    cursor: pointer;
    transition: color 0.15s ease;
}

.btn-link:hover {
    color: var(--ink);
}

/* Inside a flex-gap stage the 14px picker margin would double up. */
form.stage .btn-link,
.stage-form .btn-link,
.link-stage .btn-link {
    margin-top: 2px;
}

.btn-link:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-inline {
    width: auto;
    margin-top: 0;
    font-size: 12.5px;
}

.section-heading {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 620;
    color: var(--muted);
    letter-spacing: 0.01em;
}

/* ─── "계정 선택": the emails this device remembers (email step, 8.2) ─── */

.accounts {
    margin-bottom: 6px;
}

/* One remembered email per line, across the whole width; the × sits inside the
   line's right end (a sibling of the row's button, never inside it). */
.account-line {
    position: relative;
}

.account-line + .account-line {
    margin-top: 8px;
}

.account-line .box-row {
    padding-right: 48px;
}

.account-forget {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.account-forget:hover {
    background: var(--line);
    color: var(--ink);
}

.account-forget:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* "이 기기에서 이 이메일을 잊을까요?" [취소] [잊기] — in the line itself. */
.account-ask {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--paper);
}

.account-ask-text {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.4;
}

.account-ask .btn-small,
.account-ask .btn-link {
    flex: none;
}

/* ─── Stage 2: box picker ────────────────────────────────────────── */

.picker-heading {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 620;
    text-align: center;
}

.picker-sub {
    margin: 0 0 16px;
    font-size: 12.5px;
    color: var(--muted);
    text-align: center;
    overflow-wrap: anywhere;
}

.box-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.box-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    color: var(--ink);
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.box-row:hover {
    border-color: var(--muted);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.box-row:focus-visible {
    outline: none;
    border-color: var(--ink);
    box-shadow: var(--field-focus);
}

.box-row-icon {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
}

.box-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.box-row-name {
    font-size: 14.5px;
    font-weight: 620;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.box-row-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.box-row-badge {
    flex: none;
    font-size: 11px;
    font-weight: 560;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 3px 9px;
}

.box-row:disabled {
    cursor: progress;
}

/* ─── No Plum Box for this email ─────────────────────────────────── */

.none-found {
    text-align: center;
    padding: 8px 4px 4px;
}

.none-title {
    margin: 0 0 6px;
    font-size: 14.5px;
    font-weight: 620;
}

.none-hint {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--muted);
}

/* ─── "확인이 필요해요" — waiting entries ───────────────────────────── */

.pending-section {
    margin-top: 20px;
}

.pending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pending-card {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--paper);
    border: 1px dashed var(--line-strong);
}

.pending-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pending-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pending-name {
    font-size: 14.5px;
    font-weight: 620;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pending-meta {
    font-size: 11.5px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.pending-text {
    margin: 10px 0 10px;
    font-size: 13px;
    line-height: 1.5;
}

.pending-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    flex: 1;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-small-primary {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--surface);
}

.btn-small:disabled {
    opacity: 0.6;
    cursor: progress;
}

.btn-small:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* ─── Stage 4: chosen-box chip ───────────────────────────────────── */

.chosen-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 9px;
}

.chip-icon {
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
}

.chip-name {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 620;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-change {
    background: none;
    border: 0;
    padding: 2px 4px;
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.chip-change:hover {
    color: var(--ink);
}

.chip-change:focus-visible {
    outline: none;
    border-radius: 4px;
    box-shadow: var(--ring);
}

/* "이 기기에서 이 박스 기억하기" — off unless ticked. */
.check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    cursor: pointer;
}

.check input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--ink);
}

/* ─── No box ready: "… 지금 응답하지 않아요" ───────────────────────── */

.unreachable {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.unreachable-title {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
    overflow-wrap: anywhere;
}

.unreachable-sub {
    margin: 0 0 10px;
    font-size: 12.5px;
    color: var(--muted);
}

.unreachable-note {
    margin: 0 0 10px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--muted);
}

.unreachable .btn-link {
    margin-top: 2px;
}

/* ─── OAuth authorize banner ─────────────────────────────────────── */
/* Shown when a third-party app sent the user here to grant access. */

.oauth-banner {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--muted);
}

.oauth-banner-text {
    margin: 0;
    color: var(--ink);
}

/* The app's client_id only — never a name the app chose for itself. */
.oauth-client {
    margin: 4px 0 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

/* The same app request came back from a box before the new sign-in (M6): sign in there first. */
.oauth-loop {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.oauth-loop-text {
    margin: 0 0 4px;
    color: var(--ink);
}

.oauth-loop-link {
    color: var(--ink);
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* ─── Mail links (/approve, /remove) ─────────────────────────────── */

.link-stage {
    text-align: center;
}

.link-title {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
}

.link-body {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.link-detail {
    margin: 0;
    padding: 10px 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* ─── "I know my Plum Box address" (2026-11-02 redesign "B") ─────────
   One field with a paste button inside it; where to find the address opens
   only when asked. The row carries the field's border and focus ring. */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.address-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 6px;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.address-row:focus-within {
    border-color: var(--ink);
    box-shadow: var(--field-focus);
}

.address-row input[type="text"],
.address-row input[type="text"]:focus {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.paste-btn {
    flex: none;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.paste-btn:hover {
    border-color: var(--muted);
}

.paste-btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.help-link {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    background: none;
    border: 0;
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: color 0.15s ease;
}

.help-link:hover,
.help-link[aria-expanded="true"] {
    color: var(--ink);
}

.help-link:focus-visible {
    outline: none;
    border-radius: 6px;
    box-shadow: var(--ring);
}

.help-mark {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1.3px solid currentColor;
    border-radius: 50%;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
}

/* The question about an address this browser has not gone to (M11), with the
   warning about someone else's address under it. */
#address-confirm {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
}

#address-confirm-title {
    color: var(--ink);
    font-weight: 600;
}

/* ─── A button that waits: two sticky beads (2026-11-02, CEO pick "A") ──
   The apps' pull-to-refresh beads (PlumPullToRefresh / TwinOrbitLoader): radius
   4px, orbiting at 5.3±2.3px, 0.9 s a turn and a breath, through #plum-goo. */

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.is-busy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary.is-busy:disabled {
    opacity: 1;
}

.beads {
    position: relative;
    flex: none;
    width: 22px;
    height: 22px;
    filter: url(#plum-goo);
}

.beads-spin {
    position: absolute;
    inset: 0;
    animation: beads-spin 0.9s linear infinite;
}

.bead {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 8px;
    margin: -4px;
    border-radius: 50%;
}

/* On paper: the apps' light beads; on the ink button: their dark-mode beads. */
.bead-a { background: #5C5C64; animation: bead-a 0.9s ease-in-out infinite; }
.bead-b { background: #101012; animation: bead-b 0.9s ease-in-out infinite; }
.btn-primary .bead-a { background: #F4F4F5; }
.btn-primary .bead-b { background: #94949C; }

@media (prefers-color-scheme: dark) {
    .bead-a { background: #F4F4F5; }
    .bead-b { background: #94949C; }
    .btn-primary .bead-a { background: #5C5C64; }
    .btn-primary .bead-b { background: #101012; }
}

@keyframes beads-spin {
    from { transform: rotate(180deg); }
    to { transform: rotate(540deg); }
}

@keyframes bead-a {
    0%, 100% { transform: translateX(7.6px); }
    50% { transform: translateX(3px); }
}

@keyframes bead-b {
    0%, 100% { transform: translateX(-7.6px); }
    50% { transform: translateX(-3px); }
}

/* ─── Below the card: the trust line ─────────────────────────────── */

.trust-note {
    margin: 0;
    padding: 0 12px;
    text-align: center;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
    .stage {
        animation: none;
    }
    .otp-d.cur:empty::after {
        animation: none;
    }
    .beads-spin,
    .bead {
        animation: none;
    }
    .bead-a { transform: translateX(5.3px); }
    .bead-b { transform: translateX(-5.3px); }
}

@media (max-width: 420px) {
    .auth-box {
        padding: 36px 22px 26px;
    }
}
