:root {
    --bg-light: #f5f5f7;
    --bg-dark: #000000;
    --surface-light: #ffffff;
    --surface-dark: #11151c;
    --surface-strong-light: #eff1f4;
    --surface-strong-dark: #171c24;
    --text-light: #1d1d1f;
    --text-dark: #e6e8eb;
    --muted-light: #6e6e73;
    --muted-dark: #a1a6ad;
    --border-light: rgba(15, 17, 21, 0.09);
    --border-dark: rgba(255, 255, 255, 0.11);
    --input-bg-light: #ffffff;
    --input-bg-dark: #131922;
    --accent-dark: #cc7d2f;
    --accent-light: #e89e49;
    --accent: var(--accent-dark);
    --accent-tint: rgba(204, 125, 47, 0.2);
    --app-header-height: 64px;
    --app-header-height-mobile: 58px;
    --app-header-offset: calc(var(--app-header-height) + env(safe-area-inset-top));
    --shadow-light: 0 10px 26px rgba(0, 0, 0, 0.08);
    --shadow-dark: 0 10px 28px rgba(0, 0, 0, 0.34);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    color: var(--text-dark);
    background: radial-gradient(circle at top right, rgba(228, 140, 50, 0.15), transparent 36%), var(--bg-dark);
    padding: calc(var(--app-header-offset) + 8px) 14px calc(env(safe-area-inset-bottom) + 16px);
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.light-mode {
    --accent: var(--accent-light);
    --accent-tint: rgba(232, 158, 73, 0.18);
    color: var(--text-light);
    background: radial-gradient(circle at top right, rgba(240, 169, 85, 0.15), transparent 36%), var(--bg-light);
}

body.dark-mode {
    --accent: var(--accent-dark);
    --accent-tint: rgba(204, 125, 47, 0.2);
    color: var(--text-dark);
}

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--app-header-offset);
    padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    z-index: 1200;
    background: color-mix(in srgb, #000 88%, transparent);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-dark);
}

body.light-mode .app-header {
    background: color-mix(in srgb, #f5f5f7 92%, transparent);
    border-bottom-color: var(--border-light);
}

.app-header-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header-left {
    justify-content: flex-start;
}

.app-header-right {
    justify-content: flex-end;
}

.app-header-title {
    margin: 0;
    text-align: center;
    font-size: 0.98rem;
    font-weight: 620;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-icon-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 11px;
    border: 1px solid var(--border-dark);
    background: var(--surface-strong-dark);
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.app-icon-btn:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-dark));
    background: color-mix(in srgb, var(--accent-tint) 70%, var(--surface-strong-dark));
}

.app-icon-btn:active {
    transform: scale(0.96);
}

.app-icon-btn:focus-visible,
.theme-toggle:focus-within {
    outline: 2px solid color-mix(in srgb, var(--accent) 60%, #6e6e73);
    outline-offset: 2px;
}

body.light-mode .app-icon-btn {
    border-color: var(--border-light);
    background: var(--surface-strong-light);
}

body.light-mode .app-icon-btn:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-light));
    background: color-mix(in srgb, var(--accent-tint) 78%, var(--surface-strong-light));
}

.theme-toggle {
    position: relative;
    width: 38px;
    height: 38px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    border: 1px solid var(--border-dark);
    background: var(--surface-strong-dark);
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.theme-toggle:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-dark));
    background: color-mix(in srgb, var(--accent-tint) 70%, var(--surface-strong-dark));
}

.theme-toggle:active {
    transform: scale(0.96);
}

.theme-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-knob {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.92rem;
    color: var(--muted-dark);
}

body.light-mode .theme-toggle {
    border-color: var(--border-light);
    background: var(--surface-strong-light);
}

body.light-mode .theme-toggle:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-light));
    background: color-mix(in srgb, var(--accent-tint) 78%, var(--surface-strong-light));
}

body.light-mode .theme-knob {
    color: var(--muted-light);
}

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

@media (max-width: 600px) {
    :root {
        --app-header-height: var(--app-header-height-mobile);
        --app-header-offset: calc(var(--app-header-height-mobile) + env(safe-area-inset-top));
    }

    body {
        padding-left: 10px;
        padding-right: 10px;
    }

    .app-header {
        padding-left: 10px;
        padding-right: 10px;
        gap: 6px;
    }

    .app-header-title {
        font-size: 0.86rem;
        max-width: 140px;
    }

    .app-icon-btn,
    .theme-toggle {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 10px;
    }
}
