:root {
    --bg: #faf7f2;
    --surface: #ffffff;
    --text: #2b2622;
    --muted: #7a716a;
    --border: #e6dfd6;
    --primary: #8b4513;
    --primary-dark: #6d340c;
    --start: #3b6ea5;        /* yazarın başlangıcı */
    --start-bg: #eef4fb;
    --cont: #2e8b57;         /* tamamlayanın kısmı */
    --cont-bg: #eef8f2;
    --leave: #c07a00;        /* bırakılan nokta */
    --leave-bg: #fff6e0;
    --danger: #b3261e;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(60, 40, 20, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow-wrap: anywhere;   /* boşluksuz uzun kelimeler kutudan taşmasın */
}

/* Grid/flex öğeleri içerikleri yüzünden genişlemesin */
.story-grid > *, .cat-grid > *, .story-card, .part, .leave-marker > div, .completion-head > * { min-width: 0; }

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

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-family: Georgia, serif; font-size: 1.35rem; font-weight: bold; color: var(--text); }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: var(--text); }
/* Dil seçici */
.lang-switch { position: relative; }
.lang-switch summary {
    list-style: none; cursor: pointer; padding: 4px 10px; border: 1px solid var(--border);
    border-radius: 999px; font-size: .85rem; user-select: none;
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch ul {
    position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow); min-width: 140px; z-index: 20;
}
.lang-switch li a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); }
.lang-switch li a:hover { background: var(--bg); text-decoration: none; }
.lang-switch li a.active { font-weight: bold; color: var(--primary); }

.menu-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; }

.cat-bar { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
.cat-bar a {
    white-space: nowrap; font-size: .85rem; padding: 4px 10px; border-radius: 999px;
    border: 1px solid var(--border); color: var(--text); background: var(--bg);
}
.cat-bar a:hover, .cat-bar a.active { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }

/* Buttons */
.btn {
    display: inline-block; background: var(--primary); color: #fff !important; border: 0;
    padding: 10px 18px; border-radius: 8px; font-size: 1rem; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--primary) !important; border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8c1d17; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-success { background: var(--cont-bg); border-color: #b6e0c6; color: #1d5c39; }
.flash-error { background: #fdecea; border-color: #f3c1bd; color: var(--danger); }
.flash-info { background: var(--start-bg); border-color: #c3d7ee; color: #24507e; }

/* Hero & sections */
.hero { text-align: center; padding: 40px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 32px; }
.hero h1 { font-family: Georgia, serif; font-size: 2rem; margin: 0 0 8px; }
.hero p { color: var(--muted); max-width: 620px; margin: 0 auto 20px; }
.section-title { font-family: Georgia, serif; margin: 32px 0 16px; display: flex; align-items: center; gap: 10px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-head h1 { font-family: Georgia, serif; margin: 0; }
.empty { color: var(--muted); background: var(--surface); padding: 24px; border-radius: var(--radius); text-align: center; border: 1px dashed var(--border); }
.muted { color: var(--muted); font-size: .9rem; }

/* Category grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.cat-tile {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); text-align: center; transition: transform .15s, box-shadow .15s;
}
.cat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.cat-icon { font-size: 2rem; }
.cat-name { font-weight: 600; }

/* Story cards */
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.story-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.story-card h3 { margin: 8px 0; font-family: Georgia, serif; }
.story-card h3 a { color: var(--text); }
.excerpt { color: #534a43; margin: 0 0 12px; flex: 1; }
.story-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.story-foot { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; gap: 8px; flex-wrap: wrap; }
.tag { font-size: .8rem; background: var(--bg); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; color: var(--text); }
.badge { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--border); color: var(--text); font-family: system-ui, sans-serif; }
.badge-done { background: var(--cont-bg); color: var(--cont); }
.badge-open { background: var(--leave-bg); color: var(--leave); }
.badge-draft { background: #ece8f5; color: #5b4b8a; }

/* Taslaklar ve düzenleme */
.draft-banner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 16px; padding: 10px 16px; border-radius: 8px; background: #f4f1fa; border: 1px dashed #b7a9da;
}
.draft-banner-actions, .card-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.draft-banner-actions form, .card-actions form, .pdf-actions form { margin: 0; }
.card-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.story-card-draft, .list-draft, .completion-draft { border-style: dashed; border-color: #b7a9da; }
.form-card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-card-head h1 { margin-bottom: 0; }
.note { font-size: .9rem; padding: 8px 12px; border-radius: 8px; background: #f4f1fa; color: #5b4b8a; }
.note-warn { background: var(--leave-bg); color: #7a5200; }
.card-note { font-size: .8rem; cursor: help; }
.list-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; gap: 8px; margin: 20px 0; flex-wrap: wrap; }
.filters a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); background: var(--surface); font-size: .9rem; }
.filters a.active { background: var(--text); color: #fff; border-color: var(--text); }
.pager { display: flex; justify-content: space-between; margin-top: 24px; }

/* Story page */
.story, .completion, .form-card, .auth-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.story h1 { font-family: Georgia, serif; font-size: 2rem; margin: 10px 0 20px; }

.part { border-left: 4px solid; border-radius: 0 8px 8px 0; padding: 12px 18px; }
.part-start { border-color: var(--start); background: var(--start-bg); }
.part-continue { border-color: var(--cont); background: var(--cont-bg); }
.part-label { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.part-start .part-label { color: var(--start); }
.part-continue .part-label { color: var(--cont); }
.part-body { font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; line-height: 1.8; }
.part-body p { margin: 0 0 1em; }
.part-body p:last-child { margin-bottom: 0; }
.part.compact .part-body { font-size: 1rem; opacity: .85; }

.leave-marker {
    display: flex; gap: 12px; align-items: flex-start; margin: 16px 0;
    background: var(--leave-bg); border: 1px dashed var(--leave); border-radius: 8px; padding: 12px 16px;
}
.leave-marker strong { color: var(--leave); display: block; }
.leave-marker q { font-style: italic; color: #5a4a2a; }
.leave-marker.small { font-size: .95rem; }
.leave-marker.small strong { display: inline; }
.marker-icon { font-size: 1.4rem; line-height: 1; }

.handoff {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    margin: 0; padding: 8px 14px; font-size: .85rem; font-weight: 600;
    background: var(--leave-bg); border-top: 1px dashed var(--leave); border-bottom: 1px dashed var(--leave);
}
.handoff span:first-child { color: var(--leave); }
.handoff span:last-child { color: var(--cont); }

.completion { scroll-margin-top: 120px; }
.completion:target { outline: 3px solid var(--cont); }
.completion-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.completion-no { background: var(--cont); color: #fff; font-weight: bold; border-radius: 999px; padding: 2px 10px; font-size: .85rem; }
.completion-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.completion-tabs button {
    background: var(--bg); border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px;
    cursor: pointer; font-size: .85rem; color: var(--text);
}
.completion-tabs button.active { background: var(--text); color: #fff; border-color: var(--text); }
.inline-form { margin-top: 14px; }
.pdf-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.btn-complete { background: var(--cont); }
.btn-complete:hover { background: #236b43; }
#tamamla { scroll-margin-top: 160px; }   /* #tamamla adresiyle açılınca yapışkan üst menünün altında kalmasın */

/* Tamamlama penceresi (modal) */
body.modal-open { overflow: hidden; }
.modal {
    width: min(760px, calc(100% - 32px)); max-height: calc(100vh - 48px);
    padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
    box-shadow: 0 20px 60px rgba(30, 20, 10, .35);
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(43, 38, 34, .55); }
.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-family: Georgia, serif; font-size: 1.3rem; }
.modal-close {
    background: none; border: 0; font-size: 1.2rem; cursor: pointer; color: var(--muted);
    width: 36px; height: 36px; border-radius: 50%;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body .form textarea { min-height: 200px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-story { margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--border); }
.modal-story h3 { font-family: Georgia, serif; margin: 0 0 12px; font-size: 1.05rem; color: var(--muted); }
.modal-story .part-body { font-size: 1rem; }

@media (max-width: 700px) {
    .modal { width: 100%; max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; margin: 0; }
    .modal-body { padding: 16px; }
}
.pdf-actions .btn:disabled { opacity: .6; cursor: wait; }

/* Forms */
.auth-card { max-width: 440px; margin: 20px auto; }
.auth-card h1, .form-card h1, .form-card h2 { font-family: Georgia, serif; margin-top: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
.form input, .form select, .form textarea {
    font: inherit; font-weight: normal; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
.form textarea { font-family: Georgia, serif; line-height: 1.7; resize: vertical; min-height: 180px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.form .btn { align-self: flex-start; }
.counter { font-size: .8rem; font-weight: normal; color: var(--muted); text-align: right; }
.leave-preview { background: var(--leave-bg); border: 1px dashed var(--leave); border-radius: 8px; padding: 10px 14px; font-size: .92rem; }
.leave-preview strong { color: var(--leave); margin-right: 4px; }
.leave-preview span { font-style: italic; }

/* Yönetim paneli */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 20px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
a.stat { color: var(--text); transition: transform .15s; }
a.stat:hover { transform: translateY(-2px); text-decoration: none; }
.admin-tabs { margin: 24px 0 0; }
.badge-admin { background: var(--primary); color: #fff; margin-left: 6px; }
.stat-num { font-size: 2rem; font-weight: bold; font-family: Georgia, serif; color: var(--primary); }
.admin-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.admin-filter input, .admin-filter select {
    font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.admin-filter input { flex: 1; min-width: 200px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: var(--bg); }
.admin-table .actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.admin-table .actions form { margin: 0; }
.admin-table .cell-excerpt { max-width: 320px; color: #534a43; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.list .excerpt { margin: 6px 0 0; }

.site-footer { border-top: 1px solid var(--border); padding: 20px 0; text-align: center; color: var(--muted); font-size: .9rem; }

@media (max-width: 700px) {
    .menu-toggle { display: block; }
    .nav {
        display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
        background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 16px; gap: 12px;
    }
    .nav.open { display: flex; }
    .lang-switch ul { position: static; box-shadow: none; margin-top: 6px; }
    .hero h1, .story h1 { font-size: 1.5rem; }
    .story, .completion, .form-card, .auth-card { padding: 16px; }
    .story-grid { grid-template-columns: 1fr; }

    /* Yönetim tablosu mobilde kart görünümüne geçer */
    .admin-table thead { display: none; }
    .admin-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--border); }
    .admin-table td { display: flex; gap: 8px; padding: 3px 0; border: 0; }
    .admin-table td[data-label]::before { content: attr(data-label) ':'; font-weight: 600; min-width: 90px; color: var(--muted); }
    .admin-table .actions { justify-content: flex-start; padding-top: 8px; }
}
