:root {
    color-scheme: light;
    --bg: #f6f3ee;
    --surface: #ffffff;
    --surface-strong: #0f2f2d;
    --text: #18211f;
    --muted: #65706d;
    --line: #d8ddd8;
    --accent: #1d7a68;
    --accent-dark: #105348;
    --gold: #b88734;
    --danger: #a83232;
    --shadow: 0 18px 50px rgba(15, 47, 45, 0.13);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #fbfaf7 0%, var(--bg) 100%);
    color: var(--text);
    font-family: 'Tajawal', Tahoma, Arial, sans-serif;
    line-height: 1.7;
}

button,
input,
select {
    font: inherit;
}

.tool-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
    max-width: 820px;
    margin: 0 auto 22px;
}

.hero-title {
    order: 1;
    flex: 1 1 auto;
    text-align: right;
}

.app-logo {
    order: 2;
    width: 108px;
    height: 108px;
    object-fit: contain;
    flex: 0 0 auto;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.45rem, 3.2vw, 2.9rem);
    line-height: 1.15;
    letter-spacing: 0;
}

.converter {
    max-width: 820px;
    margin: 0 auto;
}

form {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 24px;
    box-shadow: 0 10px 35px rgba(24, 33, 31, 0.08);
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.mode-switch label {
    position: relative;
}

.mode-switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.mode-switch span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9faf8;
    color: var(--muted);
    cursor: pointer;
    text-align: center;
}

.mode-switch input:checked + span {
    border-color: var(--accent);
    background: #e9f4f1;
    color: var(--accent-dark);
    font-weight: 700;
}

.date-panel {
    display: none;
}

.date-panel.is-active {
    display: block;
}

h2 {
    margin-bottom: 14px;
    font-size: 1.25rem;
}

.date-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 12px;
}

.date-grid label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 122, 104, 0.14);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
}

button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 10px 22px;
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    background: var(--accent-dark);
}

button.secondary {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--accent-dark);
}

button.secondary:hover {
    background: #f3f7f5;
}

.result {
    margin-top: 22px;
    border: 1px solid #cfe1dc;
    border-radius: 8px;
    background: #f4fbf8;
    color: var(--text);
    padding: 18px;
    text-align: center;
}

.result-label {
    margin-bottom: 6px;
    color: var(--accent-dark);
    font-weight: 700;
}

.result strong {
    display: block;
    font-size: clamp(1.25rem, 2.3vw, 1.8rem);
    line-height: 1.35;
}

.result .error {
    color: var(--danger);
}

.note {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    text-align: center;
}

@media (max-width: 820px) {
    .converter {
        max-width: none;
    }
}

@media (max-width: 560px) {
    .tool-shell {
        width: min(100% - 22px, 1120px);
        padding: 22px 0;
    }

    form {
        padding: 18px;
    }

    .hero {
        gap: 12px;
        justify-content: space-between;
    }

    .app-logo {
        width: 74px;
        height: 74px;
    }

    .mode-switch,
    .date-grid {
        grid-template-columns: 1fr;
    }

    .actions button {
        width: 100%;
    }
}
