/* 加密工具箱 — 极简样式，视觉风格对齐 encrypted_notes / n.down2.top */

:root {
    --bg: #ffffff;
    --fg: #000000;
    --muted: #6b6b6b;
    --line: #e5e5e5;
    --surface: #f4f4f4;
    --hover: #ebebeb;
    --code: #f6f6f6;
    --accent: #000000;
    --danger: #e5484d;
    --ok: #2f9e44;
    --radius: 9px;
}

html.dark {
    --bg: #000000;
    --fg: #ffffff;
    --muted: #9a9a9a;
    --line: #2e2e2e;
    --surface: #141414;
    --hover: #1e1e1e;
    --code: #111111;
    --accent: #ffffff;
    --danger: #ff6b6b;
    --ok: #51cf66;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0;
}

.hidden {
    display: none !important;
}

svg {
    display: block;
}

/* ── icon buttons ── */
.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--muted);
    flex: 0 0 auto;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.icon-btn:hover {
    background: var(--hover);
    color: var(--fg);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.only-mobile {
    display: inline-flex;
}

@media (min-width:1024px) {
    .only-mobile {
        display: none !important;
    }
}

.i-moon {
    display: none;
}

html.dark .i-moon {
    display: block;
}

html.dark .i-sun {
    display: none;
}

/* ── header ── */
.header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.header .brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    padding: 0 4px;
    text-decoration: none;
}

.header .spacer {
    flex: 1 1 auto;
}

/* 顶部居中的“最近构建” */
.build-info {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: #58a6ff;
    text-decoration: underline;
    white-space: nowrap;
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 8px;
    border-radius: var(--radius);
}

.build-info:hover {
    color: #79b8ff;
    background: var(--hover);
}

@media (max-width:640px) {
    .build-info {
        max-width: 40vw;
        font-size: 11px;
    }
}

/* ── layout ── */
.layout {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - 48px);
}

.sidebar {
    position: sticky;
    top: 48px;
    width: 244px;
    flex: 0 0 244px;
    height: calc(100vh - 48px);
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding: 12px 8px 24px;
}

.nav-group {
    font-size: 11px;
    letter-spacing: .4px;
    color: var(--muted);
    padding: 14px 10px 6px;
    text-transform: uppercase;
}

.nav-link {
    display: block;
    padding: 7px 10px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link:hover {
    background: var(--hover);
    color: var(--fg);
}

.nav-link.active {
    font-weight: 600;
    color: var(--fg);
    background: var(--surface);
}

.side-foot {
    margin-top: 18px;
    padding: 12px 10px 0;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}

.main {
    flex: 1 1 auto;
    min-width: 0;
}

.content {
    max-width: 56rem;
    margin: 0 auto;
    padding: 26px 24px 96px;
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.scrim.show {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width:1023px) {
    .sidebar {
        position: fixed;
        top: 48px;
        left: 0;
        z-index: 40;
        height: calc(100vh - 48px);
        transform: translateX(-100%);
        transition: transform .22s;
        background: var(--bg);
        width: 80vw;
        max-width: 300px;
        flex: none;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        padding: 18px 16px 80px;
    }
}

@media (min-width:1024px) {
    .scrim {
        display: none;
    }
}

/* ── tool panel ── */
.tool-head {
    margin-bottom: 18px;
}

.tool-head h1 {
    margin: 0 0 4px;
    font-size: 20px;
    line-height: 1.3;
}

.tool-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.field {
    margin: 14px 0;
}

.field>label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.form-control,
textarea,
select,
input[type=text],
input[type=number],
input[type=password] {
    width: 100%;
    padding: 9px 11px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--fg);
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}

html.dark .form-control,
html.dark textarea,
html.dark select,
html.dark input[type=text],
html.dark input[type=number],
html.dark input[type=password] {
    background: #0d0d0d;
}

.form-control:focus,
textarea:focus,
select:focus,
input:focus {
    border-color: var(--fg);
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.role-input {
    min-height: 140px;
}

.role-output {
    min-height: 140px;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.field-row .field {
    margin: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 15px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--fg);
    transition: background .15s;
}

.btn:hover {
    background: var(--hover);
}

.btn-primary {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
}

.btn-primary:hover {
    opacity: .85;
    background: var(--fg);
}

.btn svg {
    width: 16px;
    height: 16px;
}

.output-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0;
}

.output-head label {
    font-size: 12px;
    color: var(--muted);
}

.output-actions {
    display: flex;
    gap: 4px;
}

.link-btn {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 3px 9px;
    white-space: nowrap;
}

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

.output {
    min-height: 140px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    background: var(--code);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    overflow-x: auto;
}

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

.output.ok {
    color: var(--ok);
}

.hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 2px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.kv .k {
    color: var(--muted);
}

.kv .v {
    overflow-wrap: anywhere;
}

.copy-inline {
    cursor: pointer;
    border-bottom: 1px dashed var(--muted);
}

.copy-inline:hover {
    color: var(--fg);
}

/* ── toast ── */
#toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    z-index: 95;
    max-width: calc(100vw - 32px);
    padding: 9px 16px;
    border-radius: 14px;
    background: rgba(20, 20, 20, .94);
    color: #fff;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s, transform .22s;
}

html.dark #toast {
    background: rgba(245, 245, 245, .95);
    color: #000;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── 随机值按钮（IV/盐/密钥生成） ── */
.rand-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rand-wrap input {
    flex: 1;
    min-width: 0;
}

.rand-btn {
    flex: 0 0 auto;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--fg);
    font-size: 12px;
    cursor: pointer;
}

.rand-btn:hover {
    border-color: var(--accent);
}

/* ── scrollbar ── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 8px;
}
