:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #68758a;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --line: #e3e8f2;
    --soft: #eef4ff;
    --shadow: 0 18px 45px rgba(37, 99, 235, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, #e8f0ff, transparent 32rem), var(--bg);
}
a { color: inherit; }

.site-header {
    max-width: 1180px;
    margin: 0 auto;
    padding: 42px 20px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}
.site-header h1 { margin: 8px 0 10px; font-size: clamp(30px, 5vw, 52px); letter-spacing: -1px; }
.site-header p { margin: 0; color: var(--muted); max-width: 720px; line-height: 1.7; }
.admin-header h1 { font-size: clamp(28px, 4vw, 42px); }
.eyebrow { color: var(--primary); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.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;
}
.admin-link, .text-link {
    text-decoration: none;
    color: var(--primary);
    font-weight: 700;
}
.front-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.front-nav a {
    text-decoration: none;
    color: var(--primary);
    font-weight: 800;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,.72);
}
.front-nav a:hover { background: var(--soft); }
.front-nav a.is-active { color: #fff; background: var(--primary); border-color: var(--primary); }
.admin-link {
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,.72);
}
.header-actions { display: flex; gap: 10px; }

.layout {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 40px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 22px;
}
.panel, .ad-card, .login-card {
    background: rgba(255,255,255,.94);
    border: 1px solid var(--line);
    border-radius: 26px;
    box-shadow: var(--shadow);
}
.panel { padding: 24px; }
.hero-card, .converter-card, .world-card, .seo-card, .formatter-card, .timestamp-lookup-card { grid-column: 1; }
.wide-card { grid-column: 1 / -1; }
.sidebar { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 22px; }
.clock-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.label, .timestamp-grid span, .result-row span, .mini-stats span, .stat-grid span { color: var(--muted); font-size: 14px; }
#beijingClock { display: block; margin-top: 8px; font-size: clamp(28px, 5vw, 48px); letter-spacing: -1px; }
.clock-chip { background: var(--soft); color: var(--primary); padding: 8px 12px; border-radius: 999px; font-weight: 700; }
.timestamp-grid, .result-row, .stat-grid, .mini-stats { display: grid; gap: 14px; }
.timestamp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 24px; }
.timestamp-grid > div, .result-row > div, .stat-grid > div, .mini-stats > div {
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}
code { display: block; margin-top: 8px; font-size: 20px; color: #0f172a; word-break: break-all; }
.copy-btn {
    border: 0;
    margin-top: 10px;
    color: var(--primary);
    background: transparent;
    font-weight: 700;
    cursor: pointer;
}
.section-title h2 { margin: 6px 0 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.single { grid-template-columns: 1fr; }
label { display: block; color: var(--muted); font-size: 14px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); }
.result-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.hint { color: var(--muted); line-height: 1.7; font-size: 14px; }
.seo-card p { color: var(--muted); line-height: 1.8; margin: 0 0 12px; }
.formatter-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.formatter-toolbar {
    display: grid;
    grid-template-columns: 190px 160px minmax(280px, 1fr);
    gap: 14px;
    align-items: end;
    margin-bottom: 16px;
}
.formatter-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.compact-actions { min-width: 310px; }
.inline-btn { width: auto; margin-top: 0; }
.ghost-btn {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 16px;
    background: #fff;
    color: var(--primary);
    font-weight: 800;
    cursor: pointer;
}
.ghost-btn:hover { background: var(--soft); }
.formatter-workspace {
    display: grid;
    grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.1fr);
    gap: 16px;
    min-height: 68vh;
}
.editor-pane { min-width: 0; }
.editor-pane textarea {
    height: 68vh;
    min-height: 520px;
    resize: vertical;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.65;
    white-space: pre;
    overflow: auto;
}
.output-pane { display: flex; flex-direction: column; }
.output-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}
.output-head .is-error { color: #dc2626; }
.code-viewer {
    flex: 1;
    height: 68vh;
    min-height: 520px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #0f172a;
    color: #dbeafe;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.65;
}
.plain-code, .fold-code { margin: 0; padding: 14px 0; min-width: max-content; }
.plain-code { padding: 16px; white-space: pre; }
.code-line {
    display: grid;
    grid-template-columns: 28px 54px minmax(max-content, 1fr);
    align-items: start;
    min-height: 23px;
    padding-right: 14px;
}
.code-line:hover { background: rgba(148, 163, 184, .12); }
.code-line.is-hidden { display: none; }
.fold-toggle, .fold-spacer {
    width: 22px;
    height: 22px;
    margin-left: 6px;
    border-radius: 6px;
}
.fold-toggle {
    border: 1px solid rgba(191, 219, 254, .35);
    background: rgba(37, 99, 235, .2);
    color: #bfdbfe;
    cursor: pointer;
    line-height: 18px;
}
.line-no {
    color: #64748b;
    text-align: right;
    padding-right: 12px;
    user-select: none;
}
.code-line code { margin: 0; color: #e0f2fe; font-size: inherit; white-space: pre; word-break: normal; }
.empty-output {
    height: 100%;
    display: grid;
    place-items: center;
    padding: 30px;
    color: #94a3b8;
    text-align: center;
}
.error-output { color: #fecaca; }
.format-ad {
    margin-top: 18px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}
.format-ad img { width: 110px; height: 70px; margin-top: 0; }
.format-ad h3, .format-ad p { margin: 0; }
.format-ad p { margin-top: 4px; }
.world-time { margin-top: 6px; font-size: clamp(24px, 4vw, 36px); font-weight: 800; }
.timezone-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.zone-pill { padding: 12px; border-radius: 16px; background: #f8fbff; border: 1px solid var(--line); }
.zone-pill b { display: block; margin-bottom: 6px; }
.zone-pill span { color: var(--muted); font-size: 13px; }

.ad-card { padding: 18px; overflow: hidden; }
.ad-badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: #f1f5f9; color: #64748b; font-size: 12px; }
.ad-card img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 18px; margin-top: 12px; }
.ad-card h3 { margin: 14px 0 8px; }
.ad-card p { color: var(--muted); line-height: 1.7; }
.ad-card a, .ad-card button, .primary-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    color: #fff;
    background: var(--primary);
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
}
.ad-card button:disabled { background: #cbd5e1; cursor: not-allowed; }
.mini-stats { grid-template-columns: repeat(2, 1fr); margin-top: 18px; }
.mini-stats b, .stat-grid b { display: block; font-size: 28px; }
.site-footer { text-align: center; color: var(--muted); padding: 12px 20px 36px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-shell { width: min(100%, 430px); }
.login-card { padding: 30px; }
.login-card h1 { margin: 8px 0; }
.login-card p { color: var(--muted); line-height: 1.7; }
.login-card label { margin-top: 16px; }
.captcha-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 10px; align-items: end; }
.captcha-row img { width: 130px; height: 46px; cursor: pointer; border-radius: 12px; border: 1px solid var(--line); }
.primary-btn { width: 100%; margin-top: 20px; font-size: 16px; }
.primary-btn:hover, .ad-card a:hover { background: var(--primary-dark); }
.login-card .text-link { display: block; margin-top: 16px; text-align: center; }

.admin-layout { max-width: 1180px; margin: 0 auto; padding: 0 20px 40px; display: grid; gap: 22px; }
.formatter-layout { max-width: 1380px; margin: 0 auto; padding: 0 20px 40px; }
.formatter-layout .pro-formatter {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.formatter-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 18px;
    align-items: stretch;
    margin-bottom: 16px;
}
.formatter-hero > div:first-child, .format-status-card, .format-command-bar, .format-tabs, .pro-workspace {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255,255,255,.96);
    box-shadow: var(--shadow);
}
.formatter-hero > div:first-child { padding: 22px 24px; }
.formatter-hero h2 { margin: 8px 0 8px; font-size: clamp(28px, 4vw, 44px); letter-spacing: -1px; }
.formatter-hero p { margin: 0; color: var(--muted); line-height: 1.7; }
.format-status-card { padding: 20px; display: flex; flex-direction: column; justify-content: center; }
.format-status-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.format-status-card strong { margin-top: 8px; color: var(--primary); line-height: 1.5; }
.format-status-card strong.is-error { color: #dc2626; }
.format-tabs {
    display: inline-flex;
    gap: 8px;
    padding: 8px;
    margin-bottom: 14px;
}
.format-tab {
    min-width: 132px;
    border: 0;
    border-radius: 16px;
    padding: 13px 22px;
    color: #475569;
    background: transparent;
    font-weight: 900;
    cursor: pointer;
    transition: .18s ease;
}
.format-tab:hover { background: #f1f5f9; color: var(--primary); }
.format-tab.is-active {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 12px 24px rgba(37, 99, 235, .24);
}
.format-command-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    margin-bottom: 16px;
}
.indent-switch { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-weight: 800; }
.indent-switch select { width: 118px; margin: 0; padding: 11px 12px; }
.main-actions { justify-content: flex-end; }
.action-btn {
    border: 1px solid #dbe4f0;
    border-radius: 14px;
    padding: 12px 18px;
    color: #1e3a8a;
    background: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .05);
}
.action-btn:hover { transform: translateY(-1px); background: #f8fbff; }
.primary-action { border-color: transparent; color: #fff; background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.primary-action:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); }
.soft-action { color: #0369a1; background: #eff6ff; }
.danger-action { color: #b91c1c; background: #fff5f5; }
.pro-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
    min-height: calc(100vh - 310px);
    overflow: hidden;
}
.pro-workspace .editor-pane { padding: 0; }
.source-pane { border-right: 1px solid var(--line); }
.pane-head {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    color: #0f172a;
    font-weight: 900;
    background: #f8fbff;
}
.pane-head small { color: var(--muted); font-weight: 800; }
.pro-workspace .editor-pane textarea {
    height: calc(100vh - 364px);
    min-height: 620px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #0f172a;
    color: #e0f2fe;
    caret-color: #93c5fd;
    padding: 18px;
}
.pro-workspace .editor-pane textarea:focus { box-shadow: inset 0 0 0 2px rgba(37, 99, 235, .35); }
.pro-workspace .code-viewer {
    height: calc(100vh - 364px);
    min-height: 620px;
    border: 0;
    border-radius: 0;
}
.admin-form textarea { resize: vertical; }
.switch-line { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.switch-line input { width: auto; margin: 0; }
.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { color: var(--muted); }

.admin-console-page { background: #eef3fb; }
.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}
.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.admin-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 20px;
    background: rgba(255,255,255,.06);
}
.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #fff;
    font-weight: 900;
}
.admin-brand strong, .admin-brand small { display: block; }
.admin-brand small { margin-top: 4px; color: #94a3b8; }
.admin-menu { display: grid; gap: 10px; }
.admin-menu-item {
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 14px 16px;
    text-align: left;
    color: #cbd5e1;
    background: transparent;
    cursor: pointer;
}
.admin-menu-item span, .admin-menu-item small { display: block; }
.admin-menu-item span { font-size: 16px; font-weight: 900; }
.admin-menu-item small { margin-top: 4px; color: #64748b; }
.admin-menu-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-menu-item.is-active {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 16px 35px rgba(37, 99, 235, .35);
}
.admin-menu-item.is-active small { color: #dbeafe; }
.admin-side-actions { margin-top: auto; display: grid; gap: 10px; }
.admin-side-actions a {
    text-decoration: none;
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 800;
}
.admin-side-actions a:hover { color: #fff; background: rgba(255,255,255,.07); }
.admin-side-actions .logout-link { color: #fecaca; }
.admin-content { min-width: 0; padding: 28px; }
.admin-topbar {
    margin-bottom: 20px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: rgba(255,255,255,.92);
    box-shadow: var(--shadow);
}
.admin-topbar h1 { margin: 8px 0; font-size: clamp(30px, 4vw, 46px); }
.admin-topbar p { margin: 0; color: var(--muted); }
.admin-panel { display: none; }
.admin-panel.is-active { display: grid; gap: 20px; }
.console-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.console-card { box-shadow: var(--shadow); }
.form-submit-btn { width: auto; min-width: 180px; }

@media (max-width: 980px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; height: auto; }
    .admin-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-side-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .admin-content { padding: 18px; }
    .console-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .admin-menu, .admin-side-actions, .console-stats { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .site-header, .clock-head { flex-direction: column; }
    .layout { grid-template-columns: 1fr; }
    .sidebar { grid-column: 1; grid-row: auto; }
    .timestamp-grid, .result-row, .form-grid, .timezone-list, .stat-grid, .formatter-toolbar, .formatter-workspace, .format-ad { grid-template-columns: 1fr; }
    .formatter-title { flex-direction: column; }
    .formatter-actions { justify-content: flex-start; }
    .compact-actions { min-width: 0; }
    .editor-pane textarea, .code-viewer { height: 56vh; min-height: 380px; }
    .formatter-hero, .pro-workspace { grid-template-columns: 1fr; }
    .format-command-bar { flex-direction: column; align-items: stretch; }
    .format-tabs { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
    .format-tab { min-width: 0; padding: 12px 8px; }
    .main-actions { justify-content: flex-start; }
    .source-pane { border-right: 0; border-bottom: 1px solid var(--line); }
    .pro-workspace .editor-pane textarea, .pro-workspace .code-viewer { height: 52vh; min-height: 360px; }
}
