/* ── Tokens ── */
:root {
    --bg:         #ffffff;
    --bg-2:       #f5f5f5;
    --bg-3:       #ececec;
    --text:       #1a1a1a;
    --text-muted: #666666;
    --border:     #dddddd;
    --accent:     #2563eb;
    --accent-hover: #1d4ed8;
    --danger:     #dc2626;
    --radius:     6px;
    --shadow:     0 1px 3px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:         #111111;
        --bg-2:       #1e1e1e;
        --bg-3:       #2a2a2a;
        --text:       #f0f0f0;
        --text-muted: #999999;
        --border:     #333333;
        --accent:     #3b82f6;
        --accent-hover: #60a5fa;
        --danger:     #ef4444;
        --shadow:     0 1px 3px rgba(0,0,0,0.4);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Nav ── */
nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav a {
    color: var(--text);
    font-weight: 500;
}

nav a:hover { color: var(--accent); text-decoration: none; }

nav form { margin-left: auto; }

nav button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
}

nav button:hover { border-color: var(--accent); color: var(--accent); }

/* ── Layout ── */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.25rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 1.75rem 0 0.75rem; }

section { margin-top: 2rem; }

/* ── Forms ── */
form { display: flex; flex-direction: column; gap: 0.75rem; }

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    width: 100%;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

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

button[type="submit"] {
    align-self: flex-start;
    padding: 0.5rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 500;
}

button[type="submit"]:hover { background: var(--accent-hover); }

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ── Auth ── */
.auth-form {
    max-width: 380px;
    margin: 4rem auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form h1 { margin-bottom: 0; }

/* ── Errors / Badges ── */
.error {
    color: var(--danger);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border-radius: var(--radius);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

.badge {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    background: var(--bg-3);
    border-radius: 999px;
    color: var(--text-muted);
    vertical-align: middle;
}

.muted { color: var(--text-muted); font-size: 0.875rem; }

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-2); }

td button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}

td button:hover { color: var(--danger); }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-header h1 { margin-bottom: 0; }

.page-header form {
    flex-direction: row;
    align-items: center;
    margin-left: auto;
}

.page-header input[type="text"] { width: 220px; }

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    width: 100%;
}

/* ── Coaster Detail ── */
.coaster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.coaster-header h1 { margin-bottom: 0; }

dl.coaster-meta {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.9rem;
    background: var(--bg-2);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

dt { color: var(--text-muted); }
dd { font-weight: 500; }

/* ── Ride Form ── */
.ride-form {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* ── Image Gallery ── */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.gallery img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ── Timeline ── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.timeline-item {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1.1rem;
}

.timeline-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.timeline-body { font-size: 0.95rem; }

.rating {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.comment {
    margin-top: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Profile Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    gap: 0.4rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination a {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Stars (display) ── */
.stars { white-space: nowrap; }
.stars .star.full  { color: #f5a623; }
.stars .star.half  {
    background: linear-gradient(90deg, #f5a623 50%, var(--bg-3) 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stars .star.empty { color: var(--bg-3); }

/* ── Stars (input) ── */
.star-rating {
    display: flex;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    font-size: 1.8rem;
}

.star-group {
    position: relative;
    width: 1.8rem;
    height: 1.8rem;
    display: inline-block;
}

.star-full,
.star-half {
    position: absolute;
    top: 0;
    color: var(--bg-3);
    transition: color 0.1s;
    line-height: 1;
}

.star-full { left: 0; z-index: 1; }

.star-half {
    left: 0;
    width: 1.8rem;
    overflow: hidden;
    z-index: 2;
    clip-path: inset(0 50% 0 0);
}

.star-half::before { content: '★'; }

.star-full.active, .star-half.active { color: #f5a623; }
.star-full.hover,  .star-half.hover  { color: #f5a623; }

.rating-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: block;
}

.gallery-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background: var(--bg-2);
    font-size: 0.8rem;
}

.gallery-meta form { margin: 0; }

.upload-form {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Hero */
.coaster-hero {
    width: 100%;
    max-height: 380px;
    overflow: hidden;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.coaster-hero img {
    width: 100%;
    height: 380px;
    object-fit: cover;
    display: block;
}

/* Layout */
.coaster-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 640px) {
    .coaster-layout { grid-template-columns: 1fr; }
    .coaster-hero img { height: 220px; }
}

.coaster-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 4rem;
}

/* Sidebar Galerie */
.sidebar-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-gallery .gallery-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-2);
    width: 100%;
}

.upload-placeholder span:first-child { font-size: 1.5rem; }
.upload-placeholder:hover { color: var(--accent); border-color: var(--accent); }

/* Aktions-Box */
.action-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.action-box form { gap: 1rem; }

.action-box-row {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.action-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    font-size: 1rem;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    padding-top: 1.5rem;
}

.action-checkbox input { width: auto; }