:root {
    color-scheme: light;
    --navy: #102a4d;
    --navy-2: #173b70;
    --blue: #1667d9;
    --blue-2: #0e7bea;
    --sky: #eaf4ff;
    --cyan: #08a7c7;
    --green: #0c9b69;
    --red: #cf3d4f;
    --ink: #17233a;
    --muted: #65748b;
    --line: #dce5f0;
    --surface: #ffffff;
    --background: #f3f7fb;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--background); }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
code, textarea { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.app-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 95% 0, rgba(65, 169, 255, .11), transparent 28rem),
        var(--background);
}

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    min-height: 76px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    padding: 0 max(24px, calc((100vw - 1240px) / 2));
    color: #fff;
    background: linear-gradient(100deg, #0c2547 0%, #153d70 62%, #0c5f91 100%);
    box-shadow: 0 8px 30px rgba(17, 43, 77, .18);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand > div, .user-menu > span { display: flex; flex-direction: column; }
.brand strong { font-size: 16px; letter-spacing: .03em; }
.brand small, .user-menu small { color: #bcd2eb; font-size: 11px; margin-top: 2px; }
.brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(145deg, #1b8bf2, #12b7c9);
    box-shadow: inset 0 1px rgba(255, 255, 255, .35), 0 6px 16px rgba(2, 20, 50, .28);
    font-weight: 850;
    font-size: 13px;
    letter-spacing: -.02em;
}
.brand-mark.large { width: 58px; height: 58px; flex-basis: 58px; border-radius: 17px; font-size: 18px; }
.brand-mark.dark { background: linear-gradient(145deg, #183862, #071d38); }

.main-nav { height: 76px; display: flex; align-items: stretch; justify-content: center; gap: 4px; }
.main-nav a { position: relative; display: flex; align-items: center; padding: 0 18px; color: #cfe0f1; font-size: 14px; font-weight: 650; }
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.main-nav a.active { color: #fff; }
.main-nav a.active::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: #42d7e8; }
.user-menu { display: flex; align-items: center; gap: 16px; text-align: right; font-size: 13px; }
.user-menu form { margin: 0; }
.link-button { border: 1px solid rgba(255,255,255,.24); border-radius: 9px; padding: 8px 12px; color: #fff; background: rgba(255,255,255,.08); }
.link-button:hover { background: rgba(255,255,255,.16); }

.page-shell { width: min(1240px, calc(100% - 36px)); margin: 32px auto 60px; }
.page-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading-row h1 { margin: 3px 0 7px; font-size: clamp(25px, 3vw, 34px); line-height: 1.2; letter-spacing: -.03em; }
.page-heading-row p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.clock-card, .stat-strip { display: flex; align-items: center; gap: 15px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.76); box-shadow: 0 8px 24px rgba(28,56,92,.05); }
.clock-card { flex-direction: column; align-items: flex-start; gap: 2px; min-width: 208px; }
.clock-card span, .clock-card small { color: var(--muted); font-size: 11px; }
.clock-card strong { font-size: 15px; }
.stat-strip span { min-width: 92px; display: flex; flex-direction: column; text-align: center; }
.stat-strip span + span { border-left: 1px solid var(--line); }
.stat-strip b { color: var(--navy-2); font-size: 24px; }
.stat-strip small { color: var(--muted); }

.card { border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: var(--surface); box-shadow: 0 12px 35px rgba(27, 53, 87, .07); }
.card-title { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.card-title > div { display: flex; align-items: center; gap: 13px; }
.card-title h2 { margin: 0 0 3px; font-size: 18px; }
.card-title p { margin: 0; color: var(--muted); font-size: 12px; }
.card-title.compact { margin-bottom: 16px; }
.step-number { width: 38px; height: 38px; display: inline-grid; flex: 0 0 38px; place-items: center; border-radius: 11px; color: #fff; background: linear-gradient(145deg, var(--blue), var(--cyan)); font-size: 12px; font-weight: 850; }
.step-number.pale { color: var(--navy-2); background: var(--sky); }
.privacy-badge, .status-pill { align-self: center; border-radius: 999px; padding: 7px 10px; color: #147452; background: #e7f8f1; font-size: 11px; font-weight: 700; }
.card-title-meta { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.conversion-stamp { --stamp-color: var(--blue); display: flex; align-items: center; gap: 8px; min-height: 34px; border: 1px solid #cfe0f2; border-radius: 10px; padding: 6px 10px; color: var(--navy-2); background: #f3f8fe; white-space: nowrap; }
.conversion-stamp small { color: var(--muted); font-size: 10px; font-weight: 650; }
.conversion-stamp time { color: var(--stamp-color); font-size: 12px; font-weight: 850; letter-spacing: .01em; animation: stamp-arrive .42s ease-out; }
.conversion-stamp.tone-0 { --stamp-color: #1667d9; }
.conversion-stamp.tone-1 { --stamp-color: #7b3fc6; }
.conversion-stamp.tone-2 { --stamp-color: #c65318; }
.conversion-stamp.tone-3 { --stamp-color: #07835b; }
.conversion-stamp.tone-4 { --stamp-color: #c23865; }
@keyframes stamp-arrive { from { opacity: .35; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
.platform-icon { width: 34px; height: 34px; display: inline-grid; flex: 0 0 34px; place-items: center; border-radius: 10px; font-weight: 850; }
.platform-icon.android { color: #087554; background: #dff8ed; }
.platform-icon.ios { color: #375272; background: #e9eef5; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(280px, .8fr); gap: 18px; align-items: start; }
.converter-workspace { display: block; width: 100%; }
.converter-card { width: 100%; padding: 28px 30px 30px; }
.converter-card textarea { min-height: 190px; }
.converter-form > label:first-of-type { display: flex; justify-content: space-between; }
.counter-complete { color: var(--green); font-weight: 800; }
label { display: block; }
label > span:first-child, fieldset legend { display: block; margin-bottom: 8px; color: #273d5c; font-size: 13px; font-weight: 750; }
label > small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; }
input:not([type=checkbox]), select, textarea {
    width: 100%;
    border: 1px solid #c9d6e5;
    border-radius: 11px;
    padding: 11px 12px;
    color: var(--ink);
    outline: none;
    background: #fbfdff;
    transition: border-color .16s, box-shadow .16s, background .16s;
}
textarea { resize: vertical; line-height: 1.6; overflow-wrap: anywhere; }
input:not([type=checkbox]):focus, select:focus, textarea:focus { border-color: #4697ec; background: #fff; box-shadow: 0 0 0 4px rgba(37, 132, 232, .11); }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.toggle-card { display: flex; align-items: center; gap: 11px; min-height: 64px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfe; }
.toggle-card input { width: 18px; height: 18px; accent-color: var(--blue); }
.toggle-card span { display: flex; flex-direction: column; gap: 2px; }
.toggle-card b { font-size: 13px; }
.toggle-card small { color: var(--muted); font-size: 11px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 0; border-radius: 11px; padding: 10px 17px; font-weight: 750; text-decoration: none; transition: transform .14s, box-shadow .14s, filter .14s; }
.button:hover { transform: translateY(-1px); filter: brightness(1.03); }
.button.primary { color: #fff; background: linear-gradient(105deg, #145ed0, #0e8be8); box-shadow: 0 8px 18px rgba(20, 103, 217, .2); }
.button.secondary { color: #1b4e86; background: #e6f1fc; }
.button.success { color: #fff; background: var(--green); }
.button.dark { color: #fff; background: linear-gradient(105deg, #102a4d, #24537e); }
.button.danger { color: #a72c3b; background: #fdebed; }
.button.wide { width: 100%; }
.convert-button { width: 100%; flex-direction: column; min-height: 58px; }
.convert-button small { color: #d9edff; font-size: 10px; font-weight: 500; }
.launch-button { display: none; }
.launch-button.is-visible { display: inline-flex; }

.result-card { margin-top: 18px; padding: 22px 26px 24px; scroll-margin-top: 96px; }
.result-heading { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.result-heading .status-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 22px; font-weight: 850; }
.error-result .status-icon { background: var(--red); }
.result-heading > div:nth-child(2) { flex: 1; }
.result-heading h2 { margin: 3px 0; font-size: 20px; }
.result-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.result-heading-meta { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-left: auto; }
.result-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 380px); gap: 28px; align-items: stretch; padding-top: 16px; }
.result-output { min-width: 0; align-self: center; }
.result-output label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.result-output textarea { height: 126px; min-height: 126px; max-height: 126px; resize: none; background: #f7fbff; }
.result-actions { display: flex; gap: 9px; margin-top: 10px; }
.qr-card { width: 100%; margin: 0; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 12px; text-align: center; background: linear-gradient(180deg, #fff, #fbfdff); }
.qr-code { width: min(330px, 100%); height: auto; aspect-ratio: 1; margin: 0 auto; padding: 3px; background: #fff; }
.qr-code canvas, .qr-code img, .qr-code table, .qr-code svg { display: block; width: 100% !important; height: 100% !important; }
.qr-card figcaption { margin-top: 7px; color: var(--muted); font-size: 11px; }
.error-result > .alert { margin-top: 18px; }
.error-result > .alert small { display: block; margin-top: 6px; }

.alert { margin-bottom: 18px; border: 1px solid; border-radius: 11px; padding: 12px 14px; font-size: 13px; line-height: 1.55; }
.alert-success { color: #086447; border-color: #9bdac1; background: #eaf9f3; }
.alert-error { color: #9b2f3b; border-color: #edb7bd; background: #fff0f2; }

.stack-form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two-columns { grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: 13px; padding: 17px; }
fieldset legend { padding: 0 7px; }
.settings-card { margin-bottom: 18px; }
.protocol-selects { margin-bottom: 16px; }
.protocol-workspace { grid-template-columns: .8fr 1.2fr; }
.protocol-list { display: flex; flex-direction: column; }
.protocol-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid #e8eef5; }
.protocol-item > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.protocol-item code { overflow: hidden; color: var(--navy-2); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.protocol-item small { color: var(--muted); font-size: 10px; }
.danger-text { border: 0; padding: 5px; color: var(--red); background: transparent; font-size: 12px; }
.empty-state { padding: 38px 10px; color: var(--muted); text-align: center; }
.empty-state > span { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto; border-radius: 50%; color: var(--blue); background: var(--sky); font-size: 24px; }
.empty-state p { margin: 10px 0 4px; }
.empty-state small { font-size: 11px; }

.auth-body { min-height: 100vh; background: linear-gradient(125deg, #071c38 0%, #123b69 52%, #0d7797 100%); }
.auth-body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 18% 15%, rgba(45, 191, 226, .18), transparent 25rem), radial-gradient(circle at 88% 80%, rgba(68, 128, 235, .2), transparent 28rem); }
.auth-shell { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; }
.auth-panel { width: min(440px, 100%); border: 1px solid rgba(255,255,255,.5); border-radius: 22px; padding: 30px; background: rgba(255,255,255,.97); box-shadow: 0 26px 80px rgba(1, 14, 35, .35); }
.install-panel { width: min(760px, 100%); }
.auth-heading { display: flex; align-items: center; gap: 15px; margin-bottom: 24px; }
.auth-heading h1 { margin: 2px 0 5px; font-size: 25px; letter-spacing: -.03em; }
.auth-heading p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.auth-switch { margin: 20px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.captcha-row { display: grid; grid-template-columns: 1fr 130px; gap: 10px; align-items: stretch; }
.captcha-image { width: 130px; height: 44px; border: 0; border-radius: 9px; padding: 0; overflow: hidden; background: #eef6ff; }
.captcha-image img { display: block; }

.admin-create-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; }
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-title { padding: 22px 24px 0; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 16px; color: #5d6f86; background: #f3f7fb; font-size: 11px; text-align: left; white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid #e7edf4; vertical-align: middle; }
td > b, td > small { display: block; }
td > small { margin-top: 4px; color: var(--muted); }
td code { font-size: 11px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 700; }
.status-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-dot.enabled { color: #07835b; background: #e5f8f0; }
.status-dot.disabled { color: #b13c49; background: #fcecef; }
.edit-details { position: relative; }
.edit-details summary { color: var(--blue); font-weight: 700; }
.edit-details[open] { min-width: 260px; }
.edit-form { display: grid; gap: 10px; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: #f9fbfd; }
.edit-form label > span { margin-bottom: 4px; font-size: 11px; }
.edit-form input:not([type=checkbox]) { padding: 8px 9px; }
.check-line { display: flex; align-items: center; gap: 7px; }
.delete-form { margin-top: 8px; }
.user-agent { max-width: 300px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.filter-tabs { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.filter-tabs a { border-radius: 8px; padding: 8px 13px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-tabs a.active { color: #fff; background: var(--navy-2); }

@media (max-width: 980px) {
    .topbar { grid-template-columns: auto 1fr; padding: 0 18px; }
    .main-nav { grid-column: 1 / -1; grid-row: 2; height: auto; justify-content: flex-start; overflow-x: auto; }
    .main-nav a { min-height: 44px; padding: 0 13px; white-space: nowrap; }
    .main-nav a.active::after { left: 13px; right: 13px; }
    .user-menu { justify-self: end; }
    .workspace-grid, .protocol-workspace { grid-template-columns: 1fr; }
    .result-card { scroll-margin-top: 126px; }
    .result-layout { grid-template-columns: 1fr; }
    .qr-card { width: 100%; max-width: 410px; justify-self: center; }
    .admin-create-grid { grid-template-columns: 1fr 1fr; }
    .admin-create-grid .button { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
    .topbar { min-height: 64px; gap: 10px; }
    .brand small, .user-menu > span { display: none; }
    .main-nav { margin: 0 -18px; padding: 0 8px; background: rgba(5, 25, 51, .25); }
    .page-shell { width: min(100% - 20px, 1240px); margin-top: 22px; }
    .page-heading-row { align-items: flex-start; flex-direction: column; }
    .clock-card, .stat-strip { width: 100%; }
    .card { border-radius: 15px; padding: 18px; }
    .card-title { align-items: flex-start; }
    .card-title-meta { align-items: flex-end; flex-direction: column; gap: 6px; }
    .conversion-stamp { gap: 5px; padding: 5px 8px; }
    .conversion-stamp small { display: block; }
    .choice-row, .form-grid.two-columns, .admin-create-grid { grid-template-columns: 1fr; }
    .qr-card { width: 100%; max-width: 326px; justify-self: center; }
    .result-heading { align-items: flex-start; flex-wrap: wrap; }
    .result-heading-meta { width: 100%; justify-content: flex-start; margin-left: 58px; flex-wrap: wrap; }
    .auth-panel { padding: 23px 19px; }
    .auth-heading { align-items: flex-start; }
    .install-shell { place-items: start center; }
    .table-card { border-radius: 15px; }
}
