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

html {
    font-size: 16px;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ====== Header ====== */
header {
    background: #1a1a2e;
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

header a {
    font-size: 0.875rem;
    color: #93b4f5;
    transition: color 0.2s;
}

header a:hover {
    color: #fff;
}

/* ====== Container ====== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* ====== Landing hero ====== */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    text-align: center;
}

.hero h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1a1a2e;
}

.hero p {
    font-size: 1rem;
    color: #555;
    margin-bottom: 2rem;
}

.hero .input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 400px;
}

.hero .input-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
}

.hero .input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.hero .input-group input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.hero .btn-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #1a1a2e;
}

.btn-secondary:hover {
    background: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.btn-success {
    background: #059669;
    color: #fff;
}

.btn-success:hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5,150,105,0.3);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
    box-shadow: 0 4px 12px rgba(220,38,38,0.3);
}

.btn-add {
    background: #1a1a2e;
    color: #fff;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-add:hover {
    background: #16213e;
    box-shadow: 0 4px 12px rgba(26,26,46,0.3);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* ====== Forms ====== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    padding: 0.65rem 0.875rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ====== Cards Grid ====== */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.card-img-wrap {
    position: relative;
    width: 100%;
    height: 180px;
    background: #e2e8f0;
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-img-fallback {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #94a3b8;
    background: #e2e8f0;
}

.card-img-fallback svg {
    opacity: 0.6;
}

.card-img-fallback span {
    font-size: 0.8125rem;
    font-weight: 500;
}

.card-img-wrap.img-failed .card-img {
    display: none;
}

.card-img-wrap.img-failed .card-img-fallback,
.card-img-wrap.no-img .card-img-fallback {
    display: flex;
}

.card-delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: rgba(0,0,0,0.45);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 2;
}

.card:hover .card-delete-btn {
    opacity: 1;
}

.card-delete-btn:hover {
    background: #dc2626;
}

@media (hover: none) {
    .card-delete-btn {
        opacity: 1;
        background: rgba(0,0,0,0.35);
    }
}

.card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #1a1a2e;
}

.card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.card-details .detail-label {
    color: #666;
    font-weight: 500;
}

.card-details .detail-value {
    color: #1a1a2e;
    font-weight: 600;
    text-align: right;
}

.card-lists {
    margin-bottom: 1rem;
    font-size: 0.8125rem;
}

.card-lists h4 {
    font-size: 0.8125rem;
    color: #555;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.card-lists ul {
    list-style: none;
    padding: 0;
    margin-bottom: 0.5rem;
}

.card-lists ul li {
    padding: 0.15rem 0 0.15rem 1rem;
    position: relative;
    color: #444;
}

.card-lists ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.card-lists .pros li::before {
    background: #059669;
}

.card-lists .cons li::before {
    background: #dc2626;
}

.card-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.card-footer .btn {
    width: 100%;
    justify-content: center;
}

/* ====== Page header ====== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

.page-header .subtitle {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* ====== Modal ====== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: #1a1a2e;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

/* ====== Empty state ====== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* ====== Alert / Toast ====== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}

.alert.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

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

/* ====== Coding badge ====== */
.code-badge {
    display: inline-block;
    background: #e2e8f0;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #1a1a2e;
}

/* ====== Create page ====== */
.create-wrapper {
    max-width: 480px;
    margin: 3rem auto;
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.create-wrapper h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #1a1a2e;
}

.create-wrapper .subtitle {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 1.5rem;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
    .container {
        padding: 1.25rem 1rem;
    }

    .hero h2 {
        font-size: 1.5rem;
    }

    .hero .btn-group {
        flex-direction: column;
        width: 100%;
        max-width: 320px;
    }

    .hero .btn-group .btn {
        width: 100%;
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

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

    .modal {
        padding: 1.5rem;
    }

    .create-wrapper {
        padding: 1.5rem;
        margin: 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 15px;
    }

    header {
        padding: 0.75rem 1rem;
    }

    header h1 {
        font-size: 1.0625rem;
    }
}
