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

:root {
    --theme-color: #ffd166;
    --theme-color-light: #ffe0a3;
    --theme-color-dark: #b8860b;
    --theme-color-deep: #8a5a00;
    --theme-color-soft: rgba(255, 209, 102, 0.22);
    --theme-color-mid: rgba(255, 209, 102, 0.42);
    --text-color: #f0f0f0;
    --muted-color: #c8c8c8;
    --theme-bg: #0f0f0f;
    --theme-bg-strong: #0f0f0f;
}

body {
    min-height: 100vh;
    padding: 28px 18px;
    font-family: 'Segoe UI', 'Microsoft YaHei', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.75;
    color: var(--text-color);
    background:
        radial-gradient(circle at top left, rgba(255, 209, 102, 0.22), transparent 32%),
        #070707;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container { width: min(1200px, 100%); margin: 0 auto; }

header {
    text-align: center;
    padding: 34px 26px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 209, 102, 0.2);
    border-radius: 20px;
    background: var(--theme-bg-strong);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

h1 {
    margin-bottom: 10px;
    color: var(--theme-color-light);
    font-size: clamp(2.1rem, 7vw, 4rem);
    line-height: 1.12;
    text-shadow: 0 0 20px rgba(255, 209, 102, 0.38);
}

.subtitle { max-width: 820px; margin: 0 auto 16px; color: var(--text-color); font-size: 1.08rem; }

.version-badge {
    display: inline-block;
    margin-bottom: 14px;
    padding: 5px 14px;
    border-radius: 999px;
    color: var(--text-color);
    background: linear-gradient(90deg, var(--theme-color), #ffb142);
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.warning {
    max-width: 920px;
    margin: 0 auto 20px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 204, 77, 0.45);
    border-radius: 12px;
    color: var(--text-color);
    background: rgba(255, 193, 7, 0.12);
}

.main-content { display: flex; flex-direction: column; gap: 24px; }

.section {
    padding: 25px;
    border: 1px solid rgba(255, 209, 102, 0.16);
    border-radius: 18px;
    background: var(--theme-bg);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
}

h2 {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--theme-color-soft);
    color: var(--text-color);
    font-size: 1.8rem;
    line-height: 1.35;
}

.input-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--muted-color); }

textarea, input[type="text"], input[type="number"] {
    width: 100%;
    padding: 15px;
    border: 1px solid rgba(255, 209, 102, 0.28);
    border-radius: 8px;
    color: var(--text-color);
    background: rgba(7, 7, 7, 0.78);
    font-size: 1rem;
    resize: vertical;
    font-family: 'Courier New', monospace;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--theme-color);
    box-shadow: 0 0 14px rgba(255, 209, 102, 0.22);
}

textarea { min-height: 120px; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.controls-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }
.control-group { display: flex; flex-direction: column; gap: 10px; }
.key-range, .copy-hint { color: #9f9f9f; font-size: 0.9rem; }
.btn-group { display: flex; gap: 15px; margin-top: 20px; }

button {
    flex: 1;
    padding: 12px 25px;
    border: 1px solid rgba(255, 209, 102, 0.45);
    border-radius: 999px;
    color: #1a1200;
    background: linear-gradient(to right, var(--theme-color), var(--theme-color-dark));
    cursor: pointer;
    font-size: 1rem;
    font-weight: 800;
    transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

button:hover, .encrypt-btn:hover, .clear-btn:hover {
    background: linear-gradient(to right, var(--theme-color-light), var(--theme-color-deep));
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 209, 102, 0.18);
}

button:active { transform: translateY(0); }
.encrypt-btn, .clear-btn { background: linear-gradient(to right, var(--theme-color), var(--theme-color-dark)); }

.result-container {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid rgba(255, 209, 102, 0.16);
    border-radius: 8px;
    background: rgba(7, 7, 7, 0.72);
}

.result-label { color: var(--muted-color); font-size: 0.9rem; margin-bottom: 5px; }
.result {
    min-height: 40px;
    padding: 10px;
    border-radius: 5px;
    color: var(--theme-color-light);
    background: rgba(0, 0, 0, 0.3);
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    word-break: break-all;
}

.result.key-info, #key-info-result, .status-value { color: var(--theme-color); }
.lib-preview, .noise-canvas-container {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid rgba(255, 209, 102, 0.18);
    border-left: 4px solid var(--theme-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

.lib-title, .noise-canvas-label { color: var(--theme-color-light); font-weight: 800; margin-bottom: 5px; }
.lib-content { color: var(--muted-color); font-family: 'Courier New', monospace; font-size: 0.9rem; word-break: break-all; }
.status-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; }
.status-item { text-align: center; padding: 10px; border-radius: 8px; background: rgba(255, 209, 102, 0.08); }
.status-label { color: var(--muted-color); font-size: 0.9rem; margin-bottom: 5px; }
.new-feature { margin-top: 15px; padding: 15px; border: 1px solid rgba(255, 209, 102, 0.28); border-radius: 8px; background: rgba(255, 209, 102, 0.08); }
.new-feature-title { color: var(--theme-color-light); font-weight: 800; margin-bottom: 8px; font-size: 0.95rem; }
.new-feature-desc { color: var(--muted-color); font-size: 0.9rem; line-height: 1.6; }
#noise-canvas { width: 100%; height: 150px; border-radius: 5px; background: rgba(7, 7, 7, 0.9); display: block; }

footer {
    width: 100%;
    margin-top: 40px;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    text-align: center;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    body { padding: 18px 12px; }
    header, .section { padding: 20px; }
    .controls-grid, .controls-grid-4, .status-info { grid-template-columns: 1fr !important; }
    .btn-group { flex-direction: column; }
}

/* Jiami v15-specific styles extracted from jiami15_pre-4.html */
body.key-modal-open { overflow: hidden; }
.key-modal-launch { width:min(1200px,100%); margin:0 auto 24px; padding:18px; border:1px solid rgba(255,209,102,.22); border-radius:16px; background:rgba(15,15,15,.94); text-align:center; }
.key-config-button { width:min(420px,100%); flex:none; }
.key-modal-summary { margin-top:9px; color:#9f9f9f; font-size:.88rem; }
.key-modal-overlay[hidden] { display:none !important; }
.key-modal-overlay { position:fixed; inset:0; z-index:9999; display:flex; align-items:center; justify-content:center; padding:20px; background:rgba(0,0,0,.76); backdrop-filter:blur(4px); }
.key-modal-dialog { width:min(900px,100%); max-height:min(88vh,900px); display:flex; flex-direction:column; overflow:hidden; border:1px solid rgba(255,209,102,.4); border-radius:18px; color:var(--text-color); background:#101010; box-shadow:0 28px 80px rgba(0,0,0,.75),0 0 30px rgba(255,209,102,.1); }
.key-modal-header { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:20px 22px 14px; border-bottom:1px solid rgba(255,209,102,.18); }
.key-modal-header h2 { margin:0 0 4px; padding:0; border:0; font-size:1.55rem; }
.key-modal-header p { color:#aaa; font-size:.9rem; }
.key-modal-close { flex:none; width:42px; height:42px; padding:0; border-radius:50%; font-size:1.7rem; line-height:1; }
.key-modal-body { overflow-y:auto; padding:20px 22px; }
.key-modal-section + .key-modal-section { margin-top:24px; padding-top:22px; border-top:1px solid rgba(255,209,102,.18); }
.key-modal-section h3 { margin-bottom:16px; color:var(--theme-color-light); font-size:1.15rem; }
.key-modal-actions { display:flex; justify-content:flex-end; gap:12px; padding:15px 22px 20px; border-top:1px solid rgba(255,209,102,.18); }
.key-modal-actions button { flex:0 1 190px; }
.key-modal-secondary { color:var(--text-color); background:#262626; }
.key-modal-primary { color:#1a1200; }
@media(max-width:768px){ .key-modal-overlay{padding:10px}.key-modal-dialog{max-height:94vh}.key-modal-header,.key-modal-body,.key-modal-actions{padding-left:15px;padding-right:15px}.key-modal-actions{flex-direction:column}.key-modal-actions button{flex:auto;width:100%} }

.section-title-row { display:flex; align-items:center; justify-content:space-between; gap:18px; margin-bottom:20px; padding-bottom:10px; border-bottom:1px solid var(--theme-color-soft); }
.section-title-row h2 { margin:0; padding:0; border:0; }
.section-key-button { flex:0 0 auto; width:auto; min-width:190px; padding:10px 20px; font-size:.92rem; }
.key-modal-section.key-target-highlight { animation:keyTargetGlow .7s ease; }
@keyframes keyTargetGlow { 0%{box-shadow:0 0 0 rgba(255,209,102,0)} 45%{box-shadow:0 0 24px rgba(255,209,102,.28)} 100%{box-shadow:0 0 0 rgba(255,209,102,0)} }
@media(max-width:600px){ .section-title-row{align-items:stretch;flex-direction:column}.section-key-button{width:100%;min-width:0} }

.key-button-error-popup { position:fixed; z-index:2147483647; padding:12px 14px; border:1px solid #ff4d6d; border-radius:10px; color:#ffd4dc; background:#2b0f17; box-shadow:0 12px 30px rgba(0,0,0,.58); font-size:13px; line-height:1.45; pointer-events:none; }
.key-button-error-popup strong { display:block; margin-bottom:6px; color:#ff9bad; }
.key-button-error-popup ul { margin:0; padding-left:18px; }
.key-button-error-popup li + li { margin-top:3px; }
.section-key-button.key-button-invalid { border-color:#ff4d6d; color:#fff; background:linear-gradient(90deg,#8a2034,#4a111e); box-shadow:0 0 0 2px rgba(255,77,109,.18); }
.section-key-button.key-button-invalid::after { content:' (' attr(data-error-count) ')'; }
.key-input-invalid { border-color:#ff4d6d !important; box-shadow:0 0 0 2px rgba(255,77,109,.2) !important; }
button:disabled { opacity:.5; cursor:not-allowed; transform:none !important; box-shadow:none !important; }

.custom-library-box { margin-top:22px; padding-top:20px; border-top:1px solid rgba(255,209,102,.18); }.custom-library-box h4 { margin-bottom:8px; color:var(--theme-color-light); }.custom-library-box input { font-size:.82rem; }

.encryption-key-tools { margin-top:16px; padding:16px; border:1px solid rgba(255,209,102,.22); border-radius:10px; background:rgba(255,209,102,.06); }.encryption-key-tools .section-key-button { width:100%; }.encryption-key-tools .key-range { margin-top:8px; text-align:center; }

.encryption-key-tools { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.encryption-key-tools .section-key-button { width:100%; }
.output-key-card { margin:0; padding:0; border:0; background:transparent; }
.output-key-dialog .result { max-height:52vh; overflow:auto; white-space:pre-wrap; }
@media(max-width:600px){ .encryption-key-tools{grid-template-columns:1fr;} }

.output-key-line { padding:9px 10px; border-bottom:1px solid rgba(255,209,102,.13); line-height:1.55; text-align:left; }
.output-key-line:last-child { border-bottom:0; }
.output-key-line strong { color:var(--theme-color-light); }
.output-key-line span { color:var(--text-color); font-family:'Courier New',monospace; }
.output-library-line span { display:block; margin-top:5px; padding:8px; border-radius:6px; background:rgba(0,0,0,.3); overflow-wrap:anywhere; white-space:pre-wrap; }
