/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --border: #e8eaed;
    --border-light: #f0f1f3;
    --text: #1a1a2e;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --accent: #1a73e8;
    --accent-hover: #1765cc;
    --accent-subtle: #e8f0fe;
    --success: #0d904f;
    --error: #d93025;
    --header-bg: #1a1a2e;
    --sidebar-w: 240px;
    --header-h: 52px;
    --radius: 8px;
    --radius-sm: 6px;
    --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
    --sans: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
}

html, body {
    height: 100%;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; color: inherit; }

/* ===== HEADER ===== */
.header {
    background: var(--header-bg);
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 20px;
    gap: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    cursor: pointer;
}

.logo-mark { opacity: 0.9; }

.logo-text-group {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.logo-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    font-weight: 400;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

.header-nav::-webkit-scrollbar { display: none; }

.nav-tag {
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
    border-radius: 100px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.nav-tag:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    height: calc(100vh - var(--header-h));
}

/* ===== SIDEBAR ===== */
.tool-sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 16px 0;
}

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-label {
    padding: 6px 20px 8px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tool-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 8px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-align: left;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

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

.tool-btn.active {
    background: var(--accent-subtle);
    border-color: rgba(26,115,232,0.12);
}

.tool-btn.active .tool-ico {
    color: var(--accent);
}

.tool-btn.active .tool-btn-text {
    color: var(--accent);
    font-weight: 600;
}

.tool-ico {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.15s;
}

.tool-btn-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.15s;
}

/* ===== MAIN CONTENT ===== */
.tool-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    max-width: 100%;
}

.tool-header {
    margin-bottom: 24px;
}

.tool-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.4px;
    line-height: 1.2;
}

.tool-subtitle {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 400;
}

/* ===== BUTTONS ===== */
.btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
}

.btn:active { transform: scale(0.96); }
.btn-row .btn { background: var(--surface); color: var(--text-secondary); border-color: var(--border); }
.btn-row .btn:hover { border-color: #ccc; color: var(--text); background: var(--bg); }
.btn-row .btn.active-action { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 1px 3px rgba(26,115,232,0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: #ccc;
    color: var(--text);
    background: var(--bg);
}

.btn-sm { padding: 5px 14px; font-size: 12.5px; }

/* ===== EDITOR ===== */
.editor-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.editor-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.textarea-box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.textarea-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.08);
}

.textarea-box textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: vertical;
    padding: 14px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    background: transparent;
    min-height: 220px;
}

.textarea-box textarea[readonly] {
    background: #fafbfc;
    color: var(--text-secondary);
}

/* ===== STATUS ===== */
.status-bar {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 8px;
    transition: all 0.2s;
}

.status-bar.success {
    background: #e6f4ea;
    color: var(--success);
}

.status-bar.error {
    background: #fce8e6;
    color: var(--error);
}

/* ===== FORM ===== */
.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.form-row label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.form-row select,
.form-row input[type="text"],
.form-row input[type="datetime-local"] {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--sans);
    outline: none;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s;
}

.form-row select:focus,
.form-row input[type="text"]:focus,
.form-row input[type="datetime-local"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.08);
}

/* ===== JSON TREE ===== */
.tree-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
    overflow: auto;
    max-height: 480px;
}

.tree-node { margin-left: 20px; }

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 4px;
    border-radius: 4px;
    transition: background 0.12s;
}

.tree-toggle:hover { background: var(--bg); }

.tree-key { color: #c41a16; font-weight: 500; }
.tree-val-str { color: var(--accent); }
.tree-val-num { color: #0d904f; }
.tree-val-bool { color: #d93025; }
.tree-val-null { color: var(--text-muted); font-style: italic; }
.tree-bracket { color: var(--text-secondary); }

/* ===== HASH ===== */
.hash-result {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-top: 12px;
}

.hash-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--mono);
    font-size: 12.5px;
}

.hash-row:last-child { border-bottom: none; }

.hash-label {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 11.5px;
    color: var(--text-muted);
    min-width: 64px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hash-value {
    color: var(--text);
    word-break: break-all;
    flex: 1;
}

/* ===== TIMESTAMP ===== */
.ts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.ts-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.ts-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

/* ===== REGEX ===== */
.regex-match {
    background: #fef3cd;
    border-radius: 3px;
    padding: 0 2px;
}

/* ===== COLOR ===== */
.color-preview {
    width: 100%;
    height: 80px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.color-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.color-input-group label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.color-input-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--mono);
    outline: none;
    transition: border-color 0.2s;
}

.color-input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.08);
}

/* ===== UUID ===== */
.uuid-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.uuid-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 13px;
    transition: background 0.12s;
}

.uuid-item:hover { background: var(--bg); }

/* ===== FOOTER ===== */
.footer {
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    background: var(--surface);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5d7da; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .tool-sidebar { display: none; }
    .editor-row { flex-direction: column; }
    .ts-grid { grid-template-columns: 1fr; }
    .color-inputs { grid-template-columns: 1fr; }
    .header-nav { display: none; }
    .tool-content { padding: 20px 16px; }
}
