:root {
    --sidebar-bg: #0a0a0a;
    --sidebar-text: #888;
    --sidebar-active: #eee;
    --accent-red: #8B0000;
    --font-head: 'Big Shoulders Display', cursive;
    --font-body: 'Cormorant Garamond', serif;
    --font-typewriter: 'Special Elite', monospace;
    --font-quote: 'Cormorant Garamond', serif;
}

/* --- Reset & Base --- */
* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    font-family: 'Cormorant Garamond', serif;
    color: #1a1a1a;
    background: #111;
}

/* --- Sidebar --- */
#sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    user-select: none;
}

/* app-title - temel stil (flex ile override edilecek altta) */
.app-title {
    text-align: center;
}

#book-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

/* Book Group */
.book-group {
    border-bottom: 1px solid #222;
}

.book-header {
    padding: 12px 15px;
    color: #ccc;
    background: #111;
    cursor: pointer;
    font-family: var(--font-head);
    font-size: 18px;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.book-header:hover {
    background: #1a1a1a;
}

.book-header:hover .book-controls {
    opacity: 1;
}

/* Chapter Item */
.chapter-item {
    padding: 8px 15px 8px 30px;
    color: #666;
    font-family: var(--font-typewriter);
    font-size: 13px;
    cursor: pointer;
    border-left: 3px solid transparent;
    display: flex;
    justify-content: space-between;
}

.chapter-item:hover {
    color: #aaa;
    background: #0e0e0e;
}

.chapter-item.active {
    color: var(--sidebar-active);
    background: #1a1a1a;
    border-left-color: var(--accent-red);
}

/* Sidebar Controls */
.sidebar-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 14px;
}

.sidebar-btn:hover {
    color: var(--accent-red);
}

.book-controls {
    opacity: 0;
    display: flex;
    gap: 5px;
}

#add-book-btn {
    background: #111;
    color: #555;
    border: none;
    border-top: 1px solid #333;
    padding: 15px;
    cursor: pointer;
    font-size: 16px;
    font-family: var(--font-head);
    letter-spacing: 1px;
    transition: 0.2s;
}

#add-book-btn:hover {
    color: var(--accent-red);
    background: #151515;
}

/* --- Main Area (Corkboard) --- */
#main-area {
    flex: 1;
    position: relative;
    background-color: #222;
    overflow: auto;
}

/* Scrollbar Styling */
#main-area::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#main-area::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#main-area::-webkit-scrollbar-thumb {
    background: #333;
    border: 1px solid #111;
}

#main-area::-webkit-scrollbar-thumb:hover {
    background: var(--accent-red);
}

#main-area::-webkit-scrollbar-corner {
    background: #1a1a1a;
}

/* Viewport for Pan/Zoom */
#viewport {
    transform-origin: 0 0;
    width: 5000px;
    height: 5000px;
    background-color: #bfa780;
    background-image: url('https://www.transparenttextures.com/patterns/cork-board.png');
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.8);
    position: absolute;
    top: 0;
    left: 0;
}

/* SVG Overlay */
#connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    pointer-events: visibleStroke;
    cursor: pointer;
    transition: stroke-width 0.2s;
}

.connection-line:hover {
    stroke-width: 6;
    stroke: #d00;
}

/* --- Items --- */
.board-item {
    position: absolute;
    cursor: grab;
    z-index: 10;
    display: flex;
    flex-direction: column;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.4);
    transition: box-shadow 0.1s;
}

.board-item:active {
    cursor: grabbing;
    box-shadow: 5px 5px 20px rgba(0, 0, 0, 0.6);
    z-index: 100 !important;
}

.board-item.selected {
    outline: 3px dashed var(--accent-red);
}

.type-note {
    background: #fdf5c9;
    color: #333;
    width: 220px;
    min-height: 160px;
    padding: 20px;
    font-family: var(--font-typewriter);
    font-size: 15px;
    transform: rotate(-1deg);
}

.type-note::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 35%;
    width: 70px;
    height: 25px;
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transform: rotate(-2deg);
}

.type-character,
.type-image {
    background: #fff;
    padding: 12px 12px 40px 12px;
    width: 200px;
    transform: rotate(1deg);
}

.item-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #ddd;
    border: 1px solid #ccc;
}

.item-label {
    margin-top: 15px;
    text-align: center;
    font-family: var(--font-typewriter);
    font-weight: bold;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.type-event {
    background: #fafafa;
    border: 1px solid #999;
    padding: 15px;
    width: 240px;
    border-radius: 2px;
}

.type-event h4 {
    margin: 0 0 10px 0;
    font-family: var(--font-head);
    text-transform: uppercase;
    color: var(--accent-red);
    border-bottom: 2px solid var(--accent-red);
    font-size: 18px;
}

.type-quote {
    background: #2a2a2a;
    color: #eee;
    width: 300px;
    padding: 25px;
    border-left: 5px solid var(--accent-red);
    font-family: var(--font-quote);
    font-style: italic;
    font-size: 16px;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.6);
}

.type-quote::before {
    content: '“';
    font-size: 60px;
    color: #555;
    position: absolute;
    top: -10px;
    left: 10px;
}

/* --- Evidence / Realistic Photo --- */
.type-evidence {
    padding: 0;
    background: none;
    box-shadow: 2px 5px 15px rgba(0, 0, 0, 0.5);
    width: auto;
    max-width: 300px;
    border: 4px solid #eee;
    transform: rotate(1deg);
}

.type-evidence img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.type-evidence::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    width: 40px;
    height: 18px;
    background: rgba(255, 255, 255, 0.35);
    border-left: 1px dotted rgba(255, 255, 255, 0.4);
    border-right: 1px dotted rgba(255, 255, 255, 0.4);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transform: translateX(-50%) rotate(-1deg);
    z-index: 20;
}

/* Controls */
#controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 10px;
    z-index: 200;
}

.control-btn {
    background: #222;
    color: #fff;
    border: 1px solid #444;
    padding: 12px 18px;
    font-family: var(--font-head);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: 0.2s;
}

.control-btn:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

#zoom-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 5px;
    z-index: 200;
}

.zoom-btn {
    background: #222;
    color: #fff;
    border: 1px solid #444;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: #444;
}

/* Alert Bar (Mini Toast) */
#alert-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: auto;
    height: auto;
    padding: 8px 15px;
    background: #333;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    font-family: var(--font-body);
    font-weight: bold;
    font-size: 12px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid #555;
    pointer-events: none;
    /* Let clicks pass through if just viewing */
}

#alert-bar button {
    display: none;
    /* Hide close button for mini toast style, usually auto-hides */
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1a1a1a;
    color: #ddd;
    padding: 30px;
    width: 500px;
    border: 1px solid #444;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    font-family: var(--font-head);
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--accent-red);
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.field-group {
    margin-bottom: 15px;
}

.field-group label {
    display: block;
    color: #888;
    margin-bottom: 5px;
    font-size: 13px;
}

.modal input[type="text"] {
    width: 100%;
    padding: 10px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    font-family: var(--font-body);
    font-size: 16px;
}

.modal textarea {
    width: 100%;
    height: 180px;
    background: #111;
    border: 1px solid #333;
    color: #ccc;
    padding: 10px;
    font-family: var(--font-typewriter);
    font-size: 15px;
    resize: vertical;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.radio-label {
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ccc;
}

.radio-label input {
    margin: 0;
}

.preview-box {
    width: 100px;
    height: 100px;
    background: #000;
    border: 1px solid #444;
    object-fit: cover;
    display: none;
}

.modal-buttons {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #666;
    cursor: pointer;
    font-size: 24px;
}

.close-modal:hover {
    color: #fff;
}

/* Character Selection Modal Styles */
.char-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.char-card {
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
    position: relative;
}

.char-card:hover {
    border-color: var(--accent-red);
    background: #2a2a2a;
}

.char-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    margin-bottom: 5px;
    background: #000;
}

.char-card span {
    font-family: var(--font-typewriter);
    font-size: 14px;
    color: #ccc;
}

.char-card-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: #f00;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-weight: bold;
    display: none;
    border: 1px solid #f00;
    z-index: 10;
}

.char-card:hover .char-card-delete {
    display: block;
}

/* Map Pin Styling */
.map-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    /* Tip of pin at coordinates */
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
}

.map-pin:active {
    cursor: grabbing;
}

.pin-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.pin-label {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: -5px;
    white-space: nowrap;
    font-family: var(--font-body);
}

/* Connection Label (Relationship Note) */
.conn-label {
    position: absolute;
    background: #ffeb3b;
    /* Sticky note yellow */
    color: #000;
    padding: 2px 5px;
    border: 1px solid #dcdc5d;
    font-size: 11px;
    font-family: var(--font-hand);
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    /* Allow tooltip or interaction if needed */
    z-index: 15;
    transform: translate(-50%, -50%);
    /* Center on point */
    border-radius: 2px;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-card-delete:hover {
    background: #f00;
    color: #fff;
}

.char-card-edit {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: #4CAF50;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-weight: bold;
    display: none;
    border: 1px solid #4CAF50;
    z-index: 10;
}

.char-card:hover .char-card-edit {
    display: block;
}

.char-card-edit:hover {
    background: #4CAF50;
    color: #fff;
}

.btn-new-char {
    width: 100%;
    padding: 15px;
    background: transparent;
    border: 1px dashed #666;
    color: #888;
    cursor: pointer;
    font-family: var(--font-head);
    font-size: 16px;
}

.btn-new-char:hover {
    border-color: #fff;
    color: #fff;
}


/* Context Menu */
#context-menu {
    display: none;
    position: absolute;
    background: #222;
    border: 1px solid #444;
    z-index: 2100;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.6);
    width: 220px;
}

.ctx-item {
    padding: 12px 15px;
    color: #ccc;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 16px;
    border-bottom: 1px solid #333;
}

.ctx-item:hover {
    background: var(--accent-red);
    color: #fff;
}

.ctx-item:last-child {
    border-bottom: none;
}

/* DnD Placeholders */
.drag-over {
    border-bottom: 2px solid var(--accent-red) !important;
}

/* --- Character Library Dossier --- */
#library-modal {
    perspective: 2000px;
}

.dossier-folder {
    width: 800px;
    height: 700px;
    background: #c3b091;
    /* Manila Folder */
    margin: auto;
    position: relative;
    border-radius: 5px;
    box-shadow: 10px 10px 40px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    border: 1px solid #a08d70;
}

.dossier-tab {
    position: absolute;
    top: -40px;
    left: 20px;
    width: 220px;
    height: 45px;
    background: #c3b091;
    border-radius: 15px 15px 0 0;
    box-shadow: 2px -2px 5px rgba(0, 0, 0, 0.2);
    text-align: center;
    line-height: 45px;
    font-family: var(--font-typewriter);
    font-weight: bold;
    color: #4a3b2a;
    font-size: 18px;
    border: 1px solid #a08d70;
    border-bottom: none;
    z-index: 1;
}

.dossier-content {
    flex: 1;
    background: #f4f1ea;
    /* Paper Stack */
    margin: 15px 15px 15px 10px;
    padding: 0;
    box-shadow: inset 2px 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #dcdcdc;
    position: relative;
    transform-style: preserve-3d;
    overflow: hidden;
}

.dossier-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fdfae7 url('https://www.transparenttextures.com/patterns/aged-paper.png');
    padding: 40px;
    box-sizing: border-box;
    backface-visibility: hidden;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1.000);
    transform-origin: left center;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.dossier-page.active {
    transform: rotateY(0deg);
    z-index: 2;
}

.dossier-page.flipped {
    transform: rotateY(-180deg);
    z-index: 3;
}

.dossier-page.upcoming {
    transform: rotateY(0deg);
    /* Waiting behind */
    z-index: 1;
}

.page-header {
    border-bottom: 3px double #8B0000;
    margin-bottom: 25px;
    font-family: var(--font-typewriter);
    font-size: 26px;
    color: #222;
    text-transform: uppercase;
    text-align: center;
    padding-bottom: 10px;
    letter-spacing: 2px;
}

.char-entry {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    border-bottom: 1px dashed #bbb;
    padding-bottom: 15px;
    align-items: flex-start;
}

.char-entry img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
    transform: rotate(-3deg);
    background: #ddd;
}

.char-info {
    flex: 1;
}

.char-info h4 {
    margin: 0 0 5px 0;
    font-family: var(--font-typewriter);
    font-size: 18px;
    color: #000;
    text-decoration: underline;
}

.char-info p {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    white-space: pre-wrap;
    /* Preserve newlines */
}

.char-info {
    flex: 1;
}

.char-info h4 {
    margin: 0 0 8px 0;
    font-family: var(--font-head);
    font-size: 22px;
    color: #8B0000;
}

.char-info p {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    color: #333;
    line-height: 1.4;
}

.page-controls {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px 20px 20px;
    background: #c3b091;
    border-top: 1px solid #a08d70;
}

.page-btn {
    background: #4a3b2a;
    color: #fff;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-family: var(--font-head);
    letter-spacing: 1px;
}

.page-btn:disabled {
    background: #887b6a;
    cursor: default;
    opacity: 0.6;
}

/* Clipping Modal */
.clipping-headline {
    font-family: var(--font-head);
    font-size: 22px;
    font-weight: bold;
    color: #111;
    margin-bottom: 10px;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.1;
}

.clipping-body {
    font-family: var(--font-body);
    font-size: 14px;
    color: #333;
    text-align: justify;
    line-height: 1.3;
}

/* Clipping Design Overrides */
.type-clipping {
    background: #f4f1ea;
    width: 250px;
    padding: 20px;
    box-shadow: 3px 3px 12px rgba(0, 0, 0, 0.5);
    border: none;
    clip-path: polygon(0% 5%, 5% 0%, 95% 2%, 98% 0%, 100% 5%,
            99% 95%, 100% 100%, 95% 98%, 5% 100%, 0% 95%);
    /* Simple jagged edge sim */
    transform: rotate(1deg);
    overflow: hidden;
}

.type-clipping::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://www.transparenttextures.com/patterns/aged-paper.png');
    opacity: 0.5;
    pointer-events: none;
}

/* Timeline/Time Tunnel */
.timeline-item {
    background: #fff;
    border-left: 4px solid #8B0000;
    padding: 10px;
    margin-bottom: 10px;
    cursor: move;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

.timeline-item:active {
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
}

/* Map Module */
/* === HARİTA MODÜLÜ - YENİDEN TASARIM === */
#map-module {
    flex: 1;
    background: #111;
    display: none;
    align-items: stretch;
    justify-content: stretch;
    position: fixed;
    inset: 0;
    overflow: hidden;
    flex-direction: column;
}

/* Harita kaydırma/zoom alanı */
#map-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    cursor: grab;
    background: #0d0d0d;
    background-image: radial-gradient(circle, #222 1px, transparent 1px);
    background-size: 30px 30px;
}

#map-viewport:active {
    cursor: grabbing;
}

/* Zoom'lanabilir iç container */
#map-inner {
    position: absolute;
    transform-origin: 0 0;
    /* transform set by JS */
}

.map-container {
    position: relative;
    display: inline-block;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
    border: 4px solid #333;
    line-height: 0;
    /* inline-block için */
}

#crime-map-img {
    display: block;
    max-width: none;
    /* zoom ile büyür, max-width kısıtlaması yok */
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

#map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.map-pin {
    position: absolute;
    transform: translateX(-50%);
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
    transition: filter 0.15s, transform 0.15s;
}

.map-pin:hover {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.7)) brightness(1.1);
    transform: translateX(-50%) scale(1.1);
}

/* CSS ile yapılmış lokasyon balonu */
.pin-icon {
    width: 28px;
    height: 28px;
    background: radial-gradient(circle at 35% 35%, #ff6b8a, #cc1440);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg) translateY(-14px);
    border: 2.5px solid rgba(255, 255, 255, 0.6);
    display: block;
    flex-shrink: 0;
    /* Üstteki parlama efekti */
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.2),
        inset 3px 3px 6px rgba(255, 255, 255, 0.25);
}


/* Harita zoom kontrolleri */
#map-zoom-controls {
    position: absolute;
    bottom: 80px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 210;
}

#map-zoom-controls .zoom-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
    font-weight: bold;
}

/* Harita kontrol çubuğu (alt) */
#map-controls-bar {
    background: rgba(10, 10, 10, 0.95);
    border-top: 1px solid #333;
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    z-index: 210;
    flex-shrink: 0;
}

#map-controls-bar .control-btn {
    padding: 8px 14px;
    font-size: 12px;
    white-space: nowrap;
}

#map-controls-bar input[type="text"] {
    background: #111;
    color: #fff;
    border: 1px solid #444;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 2px;
    flex: 1;
    min-width: 100px;
}

.pin-label {
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    /* Yuvarlak hap (pill) şekli */
    font-size: 20px;
    font-weight: bold;
    font-family: var(--font-typewriter);
    margin-top: 6px;
    /* Balon ile etiket arası boşluk */
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.4px;
    pointer-events: none;
    backdrop-filter: blur(2px);
    /* Hafif cam efekti */
}

/* Archive CSS */
#archive-icon {
    position: fixed;
    bottom: 30px;
    left: 310px;
    /* Right of sidebar */
    width: 60px;
    height: 60px;
    background: #222;
    border: 1px solid #444;
    border-radius: 50%;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 200;
    transition: 0.2s;
}

#archive-icon:hover {
    color: #fff;
    background: #333;
}

#archive-icon.full {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.archive-item {
    background: #222;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px dotted #444;
    color: #ccc;
    font-family: var(--font-typewriter);
    display: flex;
    justify-content: space-between;
    cursor: grab;
}

.archive-item:active {
    cursor: grabbing;
}

/* Backup UI */
#backup-status {
    position: fixed;
    top: 10px;
    right: 150px;
    /* Left of zoom controls */
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #333;
    z-index: 2000;
}

#backup-status.active {
    border-color: #0f0;
    color: #aea;
}

#backup-status.inactive {
    border-color: #f00;
    color: #eaa;
}

/* =========================================
   MOBİL UYUMLULUK (Responsive Design)
   ========================================= */

/* --- Hamburger Butonu --- */
#hamburger-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 3000;
    background: #111;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #ccc;
    border-radius: 2px;
    transition: all 0.25s;
}

#hamburger-btn.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

#hamburger-btn.open span:nth-child(2) {
    opacity: 0;
}

#hamburger-btn.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* --- Sidebar Overlay (Mobil) --- */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    backdrop-filter: blur(2px);
}

#sidebar-overlay.visible {
    display: block;
}

/* --- Sidebar Kapat Butonu --- */
.sidebar-close-btn {
    display: none;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
    z-index: 1;
}

.sidebar-close-btn:hover {
    color: #fff;
}

/* --- App Title - Her zaman Flex --- */
.app-title {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
    color: var(--accent-red);
    font-family: var(--font-head);
    font-size: 24px;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
}

/* =========================================
   TABLET (768px ve altı)
   ========================================= */
@media (max-width: 768px) {

    /* Body Layout */
    body {
        overflow: hidden;
    }

    /* Hamburger Butonu Göster */
    #hamburger-btn {
        display: flex;
    }

    /* Sidebar - Varsayılan Gizli, Slide-in */
    #sidebar {
        position: fixed;
        left: -310px;
        top: 0;
        height: 100%;
        width: 280px;
        z-index: 100;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    #sidebar.open {
        left: 0;
    }

    /* Sidebar Kapat Butonu */
    .sidebar-close-btn {
        display: block;
    }

    /* Main Area - Tüm genişliği kapla */
    #main-area {
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    /* Kontrol Butonları - Aşağı, kaydırılabilir yatay */
    #controls {
        bottom: 10px;
        right: 0;
        left: 0;
        width: 100%;
        padding: 6px 8px;
        box-sizing: border-box;
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        background: rgba(20, 20, 20, 0.9);
        border-top: 1px solid #333;
        border-radius: 0;
        scrollbar-width: none;
    }

    #controls::-webkit-scrollbar {
        display: none;
    }

    .control-btn {
        padding: 10px 12px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 44px;
    }

    /* Zoom Kontrolleri - Sol üste taşı (hamburger hariç) */
    #zoom-controls {
        top: 10px;
        right: 10px;
        gap: 4px;
    }

    .zoom-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* Yedekleme Butonu */
    #backup-toggle-btn {
        top: 10px;
        right: 60px;
        font-size: 20px;
    }

    /* Arşiv İkonu */
    #archive-icon {
        bottom: 70px;
        left: 10px;
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    /* Alert Bar */
    #alert-bar {
        bottom: 70px;
        right: 10px;
        left: 10px;
        font-size: 13px;
    }

    /* Modal - Tam ekran genişlik */
    .modal-content {
        width: calc(100vw - 30px) !important;
        max-width: 100% !important;
        padding: 20px 15px;
        max-height: 85vh !important;
        overflow-y: auto;
        margin: 0 auto;
    }

    /* Dossier/Kütüphane Modal */
    .dossier-folder {
        width: calc(100vw - 20px) !important;
        height: 85vh !important;
        max-width: 100%;
    }

    .dossier-page {
        padding: 20px 15px;
    }

    .dossier-tab {
        font-size: 14px;
        width: 160px;
        height: 38px;
        line-height: 38px;
    }

    /* Karakter Gridi - 2 kolon */
    .char-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Karakter Girişi */
    .char-entry {
        flex-direction: column;
    }

    .char-entry img {
        width: 80px;
        height: 80px;
    }

    /* Textarea küçült */
    .modal textarea {
        height: 120px;
    }

    /* Modal Butonlar - dikey */
    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-buttons .control-btn {
        width: 100%;
        text-align: center;
    }

    /* Input Row - dikey */
    .input-row {
        flex-direction: column;
    }

    /* Harita Kontrol Çubuğu - Mobil */
    #map-controls-bar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px;
        justify-content: flex-start;
    }

    #map-controls-bar .control-btn {
        font-size: 11px;
        padding: 8px 10px;
        min-height: 40px;
    }

    #map-controls-bar input[type="text"] {
        font-size: 14px;
        /* Klavye açılmasını sağla */
        min-width: 80px;
    }

    /* Harita Zoom Butonları - Mobil */
    #map-zoom-controls {
        bottom: auto;
        top: 10px;
        right: 10px;
    }

    #map-zoom-controls .zoom-btn {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    /* Relation Colors */
    #relation-colors {
        flex-direction: row !important;
    }
}

/* =========================================
   KÜÇÜK MOBİL (480px ve altı)
   ========================================= */
@media (max-width: 480px) {

    #sidebar {
        width: 260px;
        left: -270px;
    }

    .app-title span {
        font-size: 16px;
    }

    .modal-header {
        font-size: 18px;
    }

    /* Kontrol butonları daha küçük */
    .control-btn {
        padding: 8px 10px;
        font-size: 11px;
        letter-spacing: 0;
    }

    /* Zoom Butonu */
    .zoom-btn {
        width: 36px;
        height: 36px;
    }

    /* Dossier */
    .dossier-folder {
        height: 90vh !important;
    }

    .char-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Board item'lar küçük ekranda daha az yer tutan */
    .type-note {
        width: 160px;
        min-height: 120px;
        font-size: 13px;
        padding: 14px;
    }

    .type-character,
    .type-image {
        width: 150px;
    }

    .item-image {
        height: 120px;
    }

    .type-event {
        width: 180px;
    }

    .type-quote {
        width: 220px;
        font-size: 14px;
    }

    .type-clipping {
        width: 200px;
    }
}

/* =========================================
   DOKUNMATIK - Touch hedef büyüklüğü
   ========================================= */
@media (hover: none) and (pointer: coarse) {

    /* Touch cihazlarda hover efektlerini kaldır */
    .book-controls {
        opacity: 1;
    }

    .char-card-delete,
    .char-card-edit {
        display: block;
        opacity: 0.7;
    }

    /* Context menu yerine daha büyük butonlar */
    .ctx-item {
        padding: 15px;
        font-size: 17px;
    }

    /* Tüm tıklanabilir öğelerin min dokunma alanı */
    .chapter-item {
        padding: 12px 15px 12px 30px;
        min-height: 44px;
    }

    .book-header {
        min-height: 48px;
    }

    #add-book-btn {
        min-height: 48px;
    }
}