/* Page Background */
body {
    background:
        radial-gradient(circle at top left, rgba(255, 70, 85, 0.14), transparent 28%),
        linear-gradient(135deg, #131722, #0f172a);
    min-height: 100vh;
}

.wrapper {
    display: flex;
    justify-content: center;
    padding: clamp(24px, 4vw, 50px) clamp(16px, 3vw, 20px) 70px;
}

/* Main Card */
.card {
    width: 100%;
    max-width: 920px;
    padding: clamp(24px, 4vw, 42px);
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.28);
}

.card-header {
    margin-bottom: 30px;
}

h1 {
    margin-bottom: 10px;
    color: #0f172a;
    font-size: clamp(2rem, 4vw, 2.8rem);
}

.subtitle {
    margin-bottom: 10px;
    color: #64748b;
}

.helper-text {
    max-width: 680px;
    color: #475569;
    line-height: 1.7;
}

/* Shared Content Sections */
.section {
    margin-bottom: 25px;
}

.section-title {
    margin-bottom: 8px;
    color: #334155;
    font-size: 14px;
    text-transform: uppercase;
}

.section-note {
    margin-bottom: 18px;
    color: #64748b;
    font-size: 0.95rem;
}

.config-panel {
    padding: 20px;
    border: 1px solid #dbe2ea;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.05);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.select-field select {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-field select:focus {
    outline: none;
    border-color: #ff4655;
    box-shadow: 0 0 0 3px rgba(255, 70, 85, 0.12);
}

.choice-panel {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #f8fafc;
}

.choice-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.choice-panel-header h3 {
    margin-bottom: 6px;
    color: #0f172a;
    font-size: 1rem;
}

.choice-panel-header p {
    color: #64748b;
    font-size: 0.92rem;
}

.choice-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.85rem;
    font-weight: 700;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.choice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
}

.choice-item input {
    accent-color: #ff4655;
}

.choice-item input:disabled + span {
    opacity: 0.65;
}

.config-helper {
    margin-top: 16px;
    color: #475569;
    line-height: 1.7;
}

.subject-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.subject-chip {
    display: inline-flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 0.88rem;
    font-weight: 600;
}

/* Semester Input */
.semester-container {
    display: grid;
    gap: 15px;
}

.semester-box {
    padding: 18px;
    border: 1px solid #dbe2ea;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.05);
}

.semester-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.semester-title {
    color: #0f172a;
    font-weight: 700;
}

.semester-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.semester-remove {
    margin-top: 0;
    padding: 8px 12px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.85rem;
}

.semester-remove:hover {
    background: #fecaca;
}

.semester-clear {
    margin-top: 0;
    padding: 8px 12px;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 0.85rem;
}

.semester-clear:hover {
    background: #cbd5e1;
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.field-group label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 600;
}

.semester-box input {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.semester-box input:focus {
    outline: none;
    border-color: #ff4655;
    box-shadow: 0 0 0 3px rgba(255, 70, 85, 0.12);
}

/* Main Actions */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

button {
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    background: #ff4655;
    color: white;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

button:hover {
    background: #e03b49;
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.add-btn {
    background: #0f172a;
}

.add-btn:hover {
    background: #1e293b;
}

/* Result */
.result {
    display: none;
    margin-top: 30px;
    padding: 24px;
    border-radius: 20px;
    background: #0f172a;
    color: #e2e8f0;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.result-card {
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.result-card:last-child {
    grid-column: 1 / -1;
}

.result h3 {
    margin-bottom: 6px;
    color: white;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.result-card p {
    color: #cbd5e1;
    line-height: 1.7;
}

.result-value {
    color: white;
    font-size: 1.6rem;
    font-weight: 700;
}

.component-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 12px;
    margin-top: 6px;
}

.component-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.component-row strong {
    color: white;
}

/* History */
.history-panel {
    margin-top: 30px;
}

.history-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.clear-history-btn {
    margin-top: 0;
    background: #e2e8f0;
    color: #0f172a;
}

.clear-history-btn:hover {
    background: #cbd5e1;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-empty,
.history-item {
    padding: 18px;
    border: 1px solid #dbe2ea;
    border-radius: 18px;
    background: #ffffff;
}

.history-empty {
    color: #64748b;
    line-height: 1.7;
}

.history-item {
    display: grid;
    gap: 14px;
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.history-item-title {
    color: #0f172a;
    font-weight: 700;
}

.history-item-time {
    color: #64748b;
    font-size: 0.9rem;
    text-align: right;
}

.history-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.history-metric {
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
}

.history-metric span {
    display: block;
    margin-bottom: 6px;
    color: #64748b;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.history-metric strong {
    color: #0f172a;
    font-size: 1.05rem;
}

/* Responsive */
@media (max-width: 900px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .wrapper {
        padding-bottom: 48px;
    }

    .result-summary {
        grid-template-columns: 1fr;
    }

    .history-header,
    .history-item-header,
    .choice-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-item-time,
    .clear-history-btn {
        text-align: left;
    }
}

@media (max-width: 600px) {
    .card {
        border-radius: 20px;
    }

    .choice-grid,
    .input-grid,
    .component-list,
    .history-item-grid {
        grid-template-columns: 1fr;
    }

    .action-row {
        flex-direction: column;
    }

    .semester-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .semester-actions {
        width: 100%;
        justify-content: flex-start;
    }

    button {
        width: 100%;
    }

    .semester-clear,
    .semester-remove {
        width: auto;
    }
}
