:root {
    color-scheme: dark;
    --bg: #111315;
    --panel: #1b2024;
    --panel-strong: #232a30;
    --line: #33414a;
    --text: #f5f7f8;
    --muted: #9fb0ba;
    --accent: #2fb7a0;
    --accent-strong: #23917f;
    --warning: #f0b84a;
    --danger: #ff6b5f;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background:
        linear-gradient(180deg, rgba(47, 183, 160, 0.1), transparent 18rem),
        linear-gradient(135deg, #111315 0%, #191f22 48%, #17191d 100%);
    color: var(--text);
}

button,
input {
    font: inherit;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0;
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 4rem;
    line-height: 1;
    font-weight: 750;
}

.topbar p {
    max-width: 36rem;
    margin-top: 12px;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.65;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: end;
    gap: 12px;
}

.locale-field {
    display: grid;
    gap: 8px;
    min-width: 8rem;
    color: var(--muted);
    font-size: 0.9rem;
}

#locale-select {
    min-height: 42px;
    border: 1px solid #43525b;
    border-radius: 8px;
    padding: 0 36px 0 12px;
    background: #121619;
    color: var(--text);
    cursor: pointer;
    outline: none;
}

#locale-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 183, 160, 0.18);
}

.local-time {
    flex: 0 0 auto;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(27, 32, 36, 0.76);
    color: var(--warning);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 24px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(27, 32, 36, 0.82);
    box-shadow: var(--shadow);
}

.search-field {
    display: grid;
    gap: 8px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

#city-search {
    width: 100%;
    min-height: 44px;
    border: 1px solid #43525b;
    border-radius: 8px;
    padding: 0 12px;
    background: #121619;
    color: var(--text);
    outline: none;
}

#city-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 183, 160, 0.18);
}

#city-search::placeholder {
    color: #73848e;
}

#add-city-btn {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 0 20px;
    background: var(--accent);
    color: #061513;
    cursor: pointer;
    font-weight: 700;
}

#add-city-btn:hover {
    background: var(--accent-strong);
    color: #ffffff;
}

.form-message {
    grid-column: 1 / -1;
    min-height: 20px;
    color: var(--warning);
    font-size: 0.92rem;
}

.clocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.clock-card {
    display: grid;
    gap: 24px;
    min-height: 210px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--panel-strong), var(--panel));
    box-shadow: var(--shadow);
}

.card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 12px;
    align-items: start;
}

.card-header h2 {
    overflow-wrap: anywhere;
    font-size: 1.35rem;
    line-height: 1.25;
}

.card-header p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.remove-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #4c3838;
    border-radius: 8px;
    background: rgba(255, 107, 95, 0.1);
    color: var(--danger);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.remove-btn:hover {
    background: rgba(255, 107, 95, 0.18);
}

.time-display {
    align-self: center;
    font-size: 3.5rem;
    line-height: 1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

.date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.4;
}

.date-display {
    overflow-wrap: anywhere;
}

.offset-display {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(240, 184, 74, 0.12);
    color: var(--warning);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 24px, 1180px);
        padding: 24px 0;
    }

    .topbar {
        display: grid;
        gap: 16px;
        align-items: start;
    }

    .local-time {
        width: 100%;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        display: grid;
        justify-content: stretch;
    }

    .locale-field {
        width: 100%;
    }

    h1 {
        font-size: 2.35rem;
    }

    .toolbar {
        grid-template-columns: 1fr;
    }

    #add-city-btn {
        width: 100%;
    }

    .clocks-grid {
        grid-template-columns: 1fr;
    }

    .time-display {
        font-size: 2.75rem;
    }
}

@media (max-width: 420px) {
    .clock-card {
        padding: 16px;
    }

    .date-row {
        display: grid;
        justify-items: start;
    }
}
