:root {
    /* Light Theme */
    --bg-color: #f2f2f7;
    --card-bg: #ffffff;
    --text-main: #000000;
    --text-muted: #6e6e73;
    --border-color: #e5e5ea;
    --primary: #007aff;
    --primary-tap: #005bb5;
    --secondary-bg: #e5e5ea;
    --secondary-tap: #d1d1d6;
    --warning: #ff3b30;
    --toolbar-bg: rgba(255, 255, 255, 0.95);
}

body.dark-mode {
    /* Dark Theme */
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-main: #ffffff;
    --text-muted: #ebebf599;
    --border-color: #38383a;
    --primary: #0a84ff;
    --primary-tap: #0066cc;
    --secondary-bg: #2c2c2e;
    --secondary-tap: #3a3a3c;
    --toolbar-bg: rgba(28, 28, 30, 0.95);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    margin: 0; padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Main Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Empty State */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 80vh; text-align: center; padding: 20px;
}
.empty-icon { font-size: 4rem; margin-bottom: 16px; }
.empty-state h2 { margin-bottom: 8px; font-weight: 600;}
.empty-state p { color: var(--text-muted); margin-bottom: 30px; }

input[type="file"] { display: none; }

/* Cards & Inputs */
.card {
    background: var(--card-bg); border-radius: 16px;
    padding: 20px; margin-bottom: 16px;
}
.card-title {
    font-size: 1.1rem; font-weight: 600; margin-bottom: 16px;
}
.input-group { margin-bottom: 16px; }
.input-group label {
    display: block; font-size: 0.85rem; color: var(--text-muted);
    margin-bottom: 6px; font-weight: 500;
}
input[type="text"], textarea {
    width: 100%; background: var(--bg-color); border: 1px solid transparent;
    color: var(--text-main); border-radius: 10px; padding: 12px; font-size: 1rem;
}
textarea { resize: vertical; }

/* Accordion */
.accordion summary {
    font-weight: 500; color: var(--primary); cursor: pointer;
    padding: 10px 0; outline: none;
}
.accordion-content { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-color); }

/* Cover Layout */
.cover-layout { display: flex; gap: 20px; align-items: center; }
.cover-preview-box {
    width: 90px; height: 135px; background: var(--bg-color);
    border-radius: 8px; overflow: hidden; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    border: 1px solid var(--border-color);
}
.cover-preview-box img { width: 100%; height: 100%; object-fit: cover; }
#cover-placeholder { font-size: 0.8rem; color: var(--text-muted); }
.cover-actions { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.cover-scroller {
    display: flex; overflow-x: auto; gap: 12px; margin-top: 16px;
    padding-bottom: 8px; scrollbar-width: none;
}
.cover-scroller::-webkit-scrollbar { display: none; }
.cover-scroller img { height: 100px; border-radius: 6px; }

/* Settings Toggle */
.setting-row { display: flex; justify-content: space-between; align-items: center; }
.setting-text strong { display: block; font-weight: 500; }
.setting-text span { font-size: 0.85rem; color: var(--text-muted); }
.toggle-switch { position: relative; width: 50px; height: 30px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--secondary-bg); transition: .4s; border-radius: 30px;
}
.slider:before {
    position: absolute; content: ""; height: 26px; width: 26px; left: 2px; bottom: 2px;
    background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* General Buttons */
.btn {
    display: inline-block; text-align: center; border-radius: 12px;
    font-weight: 600; padding: 12px; border: none; width: 100%; cursor: pointer;
}
.primary-btn { background-color: var(--primary); color: white; }
.outline-btn { background-color: transparent; border: 1px solid var(--primary); color: var(--primary); padding: 10px; }
.large-btn { padding: 16px; font-size: 1.1rem; }

/* Bottom Toolbar Styles */
.bottom-toolbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--toolbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: 16px;
    display: flex;
    gap: 12px;
    z-index: 1000;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.toolbar-btn {
    flex: 1; 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-toolbar-btn {
    background-color: var(--primary);
    color: white;
}
.primary-toolbar-btn:active { background-color: var(--primary-tap); }

.warning { color: var(--warning); display: block; margin-top: 6px; font-size: 0.85rem;}

/* Add to styles.css */
.secondary-toolbar-btn {
    background-color: var(--secondary-bg);
    color: var(--text-main);
}
.secondary-toolbar-btn:active {
    background-color: var(--secondary-tap);
}

/* Native-style Dialog */
.native-dialog {
    background: var(--card-bg);
    width: 270px;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.dialog-content {
    padding: 20px;
    text-align: center;
}
.dialog-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.dialog-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.3;
}
.dialog-buttons {
    display: flex;
    border-top: 1px solid var(--border-color);
}
.dialog-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
    color: var(--primary);
}
.cancel-btn {
    border-right: 1px solid var(--border-color);
    font-weight: 400;
}
.confirm-btn {
    font-weight: 600;
    color: var(--warning); /* Red color warns that this discards unsaved progress */
}
.dialog-btn:active {
    background-color: var(--secondary-bg);
}
