:root {
    color-scheme: light;
    --paper: #fff;
    --ink: #222;
    --secondary: #595959;
    --muted: #696969;
    --line: #dedede;
    --wash: #f6f6f6;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--ink);
    background: var(--wash);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
h1, h2, p, dl, dd { margin: 0; }
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 2px solid #333; outline-offset: 4px; }
.hidden, #reader { display: none !important; }

.site-nav, .page { width: min(calc(100% - 64px), 960px); margin-inline: auto; }
.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 68px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
}
.site-nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 600; }
.site-nav a:hover { text-decoration: underline; }
.tools-mark { width: 24px; height: 24px; background: var(--ink); border-radius: 6px; display: grid; align-content: center; justify-content: center; gap: 3px; }
.tools-mark::before, .tools-mark::after, .tools-mark i { content: ""; width: 12px; height: 1px; background: white; }
.tools-mark::after { width: 8px; }
.page { padding-bottom: 64px; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 48px 8px 40px; }
h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 500; letter-spacing: -.035em; line-height: 1.2; }
.intro p { margin-top: 12px; font-size: 16px; color: var(--secondary); }
.sim-card {
    flex: none;
    width: 80px;
    height: 96px;
    clip-path: polygon(0 0, 72% 0, 100% 24%, 100% 100%, 0 100%);
    border-radius: 8px;
    background: #353535;
    color: #eee;
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font: 500 14px/1.2 ui-monospace, monospace;
}
.chip { position: relative; width: 36px; height: 28px; border-radius: 6px; background: #c6c6c6; overflow: hidden; }
.chip::before, .chip::after { content: ""; position: absolute; }
.chip::before { inset: 9px 0; border-block: 1px solid #666; }
.chip::after { inset: -1px 10px; border: 1px solid #666; border-radius: 6px; background: #bbb; }
.sheet, .install-panel { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); overflow: hidden; }
.stage { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 20px; padding: 28px 32px; }
.stage + .stage { border-top: 1px solid var(--line); }
.step-no { align-self: start; font: 500 14px/32px ui-monospace, monospace; text-align: center; background: #f0f0f0; border-radius: 6px; }
.stage[data-state="active"] .step-no, .stage[data-state="warning"] .step-no { color: white; background: var(--ink); }
.stage[data-state="idle"] h2 { color: var(--secondary); }
h2 { font-size: 22px; line-height: 32px; font-weight: 500; }
.stage-note { margin-top: 4px; color: var(--muted); font-size: 14px; }
.upload-button {
    width: 100%; margin-top: 16px; padding: 24px;
    display: flex; align-items: center; gap: 16px;
    border: 1px dashed #a8a8a8; border-radius: 12px;
    background: #fafafa; color: var(--ink); text-align: left; cursor: pointer;
}
.upload-button:hover, .upload-button[data-dragging="true"] { background: #f0f0f0; border-color: #444; }
.file-symbol { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: white; border: 1px solid var(--line); border-radius: 8px; }
.file-symbol svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.upload-copy { flex: 1; display: grid; gap: 4px; }
.upload-copy strong { font-weight: 500; }
.upload-copy > span { color: var(--secondary); font-size: 14px; }
#formatBadge:not(:empty) { margin-top: 8px; font-size: 14px; color: var(--secondary); }
.decoded-panel, .share-block, .install-body { display: grid; gap: 16px; margin-top: 16px; }
.stage[data-state="complete"] .share-hint { display: none; }
.notice { background: var(--wash); border-inline-start: 3px solid #999; padding: 12px 16px; font-size: 15px; }
.notice.warning, .notice.error { border-color: var(--ink); }
.payload-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; padding-block: 12px; border-block: 1px solid var(--line); }
dt, .field-label { display: block; font-size: 14px; color: var(--secondary); margin-bottom: 4px; }
dd, textarea, .payload-preview { overflow-wrap: anywhere; font: 14px/1.6 ui-monospace, monospace; }
textarea, .payload-preview { display: block; width: 100%; min-height: 64px; padding: 12px; border: 1px solid var(--line); background: #fafafa; border-radius: 8px; color: var(--ink); resize: vertical; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 8px 20px; background: var(--ink); border: 1px solid transparent; color: white; border-radius: 8px; text-decoration: none; font-size: 15px; font-weight: 500; cursor: pointer; transition: background-color 140ms ease-out; }
.button:hover { background: #444; }
.button.secondary { border-color: #ccc; background: white; color: var(--ink); }
.button.secondary:hover { background: var(--wash); }
button:disabled { opacity: .55; cursor: default; }
.button svg { width: 18px; height: 18px; stroke-width: 1.5; }
.install-panel { padding: 32px; }
.esim-share .page, .esim-share .site-nav { max-width: 760px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); width: max-content; max-width: 90%; padding: 12px 20px; background: var(--ink); color: white; font-size: 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 140ms ease-out; }
.toast[data-visible="true"] { opacity: 1; }
@media (max-width: 640px) {
    .site-nav, .page { width: calc(100% - 32px); }
    .site-nav { height: 56px; }
    .intro { padding: 32px 0 24px; gap: 12px; }
    .intro p { font-size: 14px; }
    .sim-card { width: 56px; height: 72px; padding: 12px 8px 8px; font-size: 12px; }
    .chip { width: 32px; height: 24px; }
    .stage { padding: 20px 16px; grid-template-columns: 28px minmax(0,1fr); gap: 12px; }
    .stage-content { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; }
    .stage-content > h2 { grid-column: 2; grid-row: 1; }
    .stage-content > :not(h2) { grid-column: 1 / -1; }
    .stage-content, .step-no { grid-row: 1; }
    .step-no { grid-column: 1; line-height: 28px; }
    h2 { font-size: 20px; line-height: 28px; }
    .stage-note { margin-top: 8px; }
    .upload-button { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 16px; }
    .upload-button .button { grid-column: 1 / -1; }
    .drag-hint { display: none; }
    .payload-meta { grid-template-columns: 1fr; }
    .actions .button { flex: 1 1 auto; }
    .install-panel { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
    .button, .toast { transition: none; }
}
