/* ===== Random Chess Opening — clean, simple styling ===== */

:root {
    --bg: #f1efe9;
    --card: #ffffff;
    --ink: #1c1917;
    --muted: #78716c;
    --line: #e7e5e4;
    --accent: #1d7a57;
    --accent-dark: #155e43;
    --danger: #b91c1c;
    --radius: 14px;
    --shadow: 0 12px 32px rgba(28, 25, 23, 0.09);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px 60px;
    line-height: 1.5;
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px;
    width: 100%;
}

.card-narrow {
    max-width: 520px;
    margin-top: 6vh;
    text-align: center;
}

.card-wide {
    max-width: 940px;
}

/* ===== Brand / header ===== */
.brand {
    margin-bottom: 28px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    font-size: 1.9rem;
    background: var(--ink);
    color: #fff;
    border-radius: 14px;
    margin-bottom: 14px;
}

h1 {
    font-size: 1.7rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--muted);
    margin-top: 4px;
    font-size: 0.98rem;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ===== Toggle ===== */
.toggle {
    display: flex;
    background: #ecebe7;
    border-radius: 999px;
    padding: 5px;
    gap: 5px;
    margin-bottom: 22px;
}

.toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
    transition: all 0.15s ease;
    user-select: none;
    font-size: 1.02rem;
}

.toggle input:checked+.toggle-option {
    background: var(--ink);
    color: #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.toggle-option:hover:not(:checked) {
    color: var(--ink);
}

/* ===== Move field ===== */
.move-field {
    margin-bottom: 22px;
    text-align: left;
}

.move-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.move-field input[type="text"] {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 1rem;
    background: #fafaf8;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.move-field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 122, 87, 0.15);
}

.hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--muted);
}

.hidden {
    display: none !important;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 17px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
    letter-spacing: 0.2px;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-small {
    width: auto;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 10px;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.btn-ghost:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.btn-mini {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--line);
    color: var(--muted);
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-mini:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.btn-danger {
    color: var(--danger);
    border-color: #fecaca;
    background: #fef2f2;
}

.btn-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: #fee2e2;
}

/* ===== Result ===== */
.result {
    margin-top: 26px;
    padding: 28px 24px;
    background: #f7f6f2;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.result h2 {
    font-size: 1.55rem;
    margin-top: 10px;
    letter-spacing: -0.01em;
}

.result .reply {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.result .description {
    margin-top: 10px;
    color: var(--ink);
    font-size: 0.96rem;
}

.side-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.side-badge.white {
    background: #ecebe7;
    color: #292524;
    border: 1px solid #d6d3d1;
}

.side-badge.black {
    background: var(--ink);
    color: #fff;
}

/* ===== Notices ===== */
.notice {
    margin-top: 20px;
    padding: 13px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    text-align: left;
}

.notice.error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.notice.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ===== Footer link ===== */
.footer-link {
    margin-top: 26px;
}

.footer-link a {
    color: var(--muted);
    font-size: 0.88rem;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 2px;
    transition: color 0.15s ease;
}

.footer-link a:hover {
    color: var(--ink);
    border-color: var(--ink);
}

/* ===== Manage page ===== */
.form-card,
.list-card {
    margin-top: 26px;
    text-align: left;
}

.form-card h2,
.list-card h2 {
    font-size: 1.15rem;
    margin-bottom: 18px;
}

/* Filter bar above the openings list */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.list-header h2 {
    margin-bottom: 0;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--muted);
}

.filter-bar select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 0.9rem;
    background: #fff;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
}

.form-card {
    background: #faf9f6;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field-full {
    grid-column: 1 / -1;
}

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 7px;
}

.field input[type="text"],
.field select,
.field textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input[type="text"]:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 122, 87, 0.15);
}

.field textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.list-card {
    border-top: 1px solid var(--line);
    padding-top: 26px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

thead th {
    text-align: left;
    padding: 12px 14px;
    background: #f4f2ed;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #faf9f6;
}

.cell-name {
    font-weight: 600;
    white-space: nowrap;
}

.cell-reply {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--accent);
}

.cell-desc {
    color: var(--muted);
    max-width: 340px;
}

.col-actions {
    white-space: nowrap;
    text-align: right;
}

.col-actions .btn-mini {
    margin-left: 6px;
}

.inline-form {
    display: inline;
}

.empty {
    color: var(--muted);
    padding: 20px 0;
}

/* ===== Status badge (active / paused) ===== */
.status-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.status-active {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-paused {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fde68a;
}

/* Paused rows are visually muted */
.row-paused .cell-name,
.row-paused .cell-desc {
    color: var(--muted);
    opacity: 0.72;
}

/* Pause / Resume buttons */
.btn-pause {
    color: #a16207;
    border-color: #fde68a;
    background: #fefce8;
}

.btn-pause:hover {
    border-color: #a16207;
    color: #a16207;
    background: #fef9c3;
}

.btn-resume {
    color: #166534;
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.btn-resume:hover {
    border-color: #166534;
    color: #166534;
    background: #dcfce7;
}

/* ===== Checkbox ===== */
.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 2px;
}

.checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

@media (max-width: 640px) {
    .card {
        padding: 24px 18px;
    }

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

    .field-full {
        grid-column: auto;
    }

    .brand-row {
        flex-direction: column;
        align-items: flex-start;
    }
}