:root {
    --bg: #f3f4f6;
    --bg-elevated: #ffffff;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.08);
    --accent-strong: rgba(37, 99, 235, 0.16);
    --border-subtle: rgba(148, 163, 184, 0.55);
    --text-main: #0f172a;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;
    --danger: #ef4444;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.18);
    --shadow-subtle: 0 1px 2px rgba(148, 163, 184, 0.35);
}

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

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #e5e7eb 0, #f9fafb 45%, #e5e7eb 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 32px 16px;
}

.page {
    width: 100%;
    max-width: 1120px;
    border-radius: 24px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 60%),
        radial-gradient(circle at bottom right, rgba(5, 150, 105, 0.06), transparent 60%),
        var(--bg-elevated);
    box-shadow: var(--shadow-soft);
    padding: 28px 24px 24px;
    border: 1px solid rgba(148, 163, 184, 0.45);
}

.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.header-main {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.8rem;
    letter-spacing: -0.04em;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.page-header h1::before {
    content: "";
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: conic-gradient(from 180deg, #2563eb, #0ea5e9, #22c55e, #2563eb);
    box-shadow: 0 0 22px rgba(37, 99, 235, 0.7);
}

.page-header p {
    margin: 4px 0 0;
    font-size: 0.98rem;
    color: var(--text-muted);
}

.search-form {
    min-width: 260px;
}

.search-field {
    position: relative;
}

.search-field input[type="search"] {
    width: 100%;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.8);
    background: #f9fafb;
    padding: 8px 12px 8px 12px;
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.25);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, transform 0.05s ease;
}

.search-field input[type="search"]::placeholder {
    color: var(--text-soft);
}

.search-field input[type="search"]:focus {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.65);
    transform: translateY(-0.5px);
}

.card {
    border-radius: var(--radius-lg);
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow: var(--shadow-subtle);
    padding: 18px 18px 16px;
}

.add-card {
    margin-bottom: 22px;
    position: relative;
    overflow: hidden;
}

.add-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 0 0, rgba(37, 99, 235, 0.12), transparent 70%);
    opacity: 0.9;
    pointer-events: none;
}

.add-card h2 {
    margin: 0 0 12px;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.add-form {
    display: grid;
    grid-template-columns: minmax(0, 2.5fr) minmax(0, 2fr);
    gap: 16px 18px;
    position: relative;
    z-index: 1;
}

.add-form .field:nth-child(2),
.add-form .field:nth-child(3) {
    grid-column: 1 / -1;
}

.add-form .field:nth-child(4) {
    grid-column: 1 / -1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-soft);
}

.field input[type="url"],
.field input[type="text"],
.field input[type="file"],
.field textarea {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.85);
    background: #f9fafb;
    padding: 9px 11px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, transform 0.05s ease;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.2);
}

.field textarea {
    resize: vertical;
    min-height: 70px;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--text-soft);
}

.field input[type="file"] {
    padding: 6px 11px;
    cursor: pointer;
    background: #ffffff;
}

.field input[type="url"]:focus,
.field input[type="text"]:focus,
.field input[type="file"]:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.6);
    background: #ffffff;
    transform: translateY(-0.5px);
}

.field .hint {
    font-size: 0.75rem;
    color: var(--text-soft);
    margin: 0;
}

.actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    grid-column: 1 / -1;
}

.actions button {
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: white;
    font-weight: 600;
    padding: 9px 18px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.actions button::after {
    content: "＋";
    font-size: 0.95rem;
}

.actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.45);
}

.actions button:active {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.35);
}

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

.site-card {
    padding: 0;
    overflow: hidden;
    background: linear-gradient(150deg, #ffffff, #f9fafb);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.6);
    position: relative;
    transition: box-shadow 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
}

.site-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.site-media {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    max-height: 150px;
}

.site-media img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.site-placeholder {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 0 0, var(--accent-soft), transparent 60%),
        radial-gradient(circle at 100% 100%, rgba(37, 99, 235, 0.16), transparent 55%),
        linear-gradient(135deg, #eff6ff, #e0f2fe);
}

.site-placeholder span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.9);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), 0 8px 18px rgba(148, 163, 184, 0.7);
    font-weight: 700;
    font-size: 1.2rem;
    color: #111827;
}

.site-content {
    padding: 12px 13px 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.site-content h3 {
    margin: 0;
    font-size: 0.98rem;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.site-url {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    word-break: break-all;
}

.site-description {
    margin: 2px 0 0;
    font-size: 0.82rem;
    color: #111827;
    max-height: 3.5em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.inline-form {
    margin: 0;
}

.btn {
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 4px 10px;
    font-size: 0.78rem;
    line-height: 1.3;
    cursor: pointer;
    background: #e5e7eb;
    color: #111827;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.btn:hover {
    background: #d1d5db;
}

.btn-secondary {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #1d4ed8;
}

.btn-secondary:hover {
    background: #e0e7ff;
}

.btn-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fee2e2;
}

.site-card:hover .site-media img {
    transform: scale(1.04);
}

.site-card:hover {
    border-color: rgba(37, 99, 235, 0.9);
    box-shadow: 0 18px 40px rgba(148, 163, 184, 0.75);
    transform: translateY(-1px);
}

.empty {
    margin: 10px 0 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.page-footer {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.55);
    font-size: 0.75rem;
    color: var(--text-soft);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.page-footer code {
    padding: 2px 5px;
    border-radius: 6px;
    background: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.9);
}

@media (max-width: 900px) {
    .header-main {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form {
        width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px 10px;
    }

    .page {
        padding: 18px 14px 18px;
        border-radius: 20px;
    }

    .add-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (min-width: 1200px) {
    .grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
