:root {
    --bg-app: #0f0f13;
    --bg-panel: #18181b;
    --bg-input: #27272a;
    --text-main: #e4e4e7;
    --text-muted: #a1a1aa;
    --accent: #d4af37;
    /* Metallic Gold */
    --accent-glow: rgba(212, 175, 55, 0.2);
    --border: #3f3f46;
    --font-heading: 'Cinzel', serif;
    /* Classic feel */
    --font-body: 'Inter', sans-serif;
    --nav-width: 280px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.hidden {
    display: none !important;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Landing Screen */
#landing-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1f1f25 0%, #0f0f13 100%);
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#landing-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.landing-content {
    text-align: center;
    max-width: 600px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.landing-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

h1.app-title {
    font-family: var(--font-heading);
    font-size: 4rem;
    color: var(--accent);
    margin-bottom: 1rem;
    text-shadow: 0 0 20px var(--accent-glow);
    letter-spacing: 2px;
}

p.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 3rem;
    line-height: 1.6;
}

.btn-primary {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 1rem 2rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    font-family: var(--font-body);
}

.btn-primary:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 30px var(--accent-glow);
}

/* App Layout */
#app-container {
    display: flex;
    height: 100vh;
    opacity: 0;
    transition: opacity 0.5s ease 0.5s;
    /* Wait for landing fade out */
}

#app-container.visible {
    opacity: 1;
}

/* Sidebar */
aside {
    width: var(--nav-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: 100%;
}

.sidebar-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-brand {
    font-family: var(--font-heading);
    color: var(--accent);
    font-size: 1.5rem;
}

.category-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.category-group {
    margin-bottom: 2rem;
}

.category-title {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.add-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.add-btn:hover {
    color: var(--accent);
}

.file-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.file-item.active {
    background-color: rgba(212, 175, 55, 0.1);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

/* Main Editor */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background-image:
        radial-gradient(circle at 50% 0%, #1f1f25 0%, transparent 50%),
        linear-gradient(to bottom, transparent, var(--bg-app));
}

header.top-bar {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(15, 15, 19, 0.8);
    backdrop-filter: blur(10px);
}

.file-status {
    font-size: 0.9rem;
    color: var(--text-muted);
}

#editor-area {
    flex: 1;
    overflow-y: auto;
    padding: 3rem 15%;
    outline: none;
}

/* Paper/Page Effect */
.page {
    max-width: 800px;
    margin: 0 auto;
    min-height: 80vh;
    color: var(--text-main);
    font-size: 1.1rem;
    line-height: 1.8;
}

.page h1#doc-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--text-main);
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
}

#doc-content {
    outline: none;
    white-space: pre-wrap;
}

/* Links within text */
.story-link {
    color: var(--accent);
    border-bottom: 1px dashed var(--accent);
    cursor: pointer;
    transition: all 0.2s;
}

.story-link:hover {
    background-color: rgba(212, 175, 55, 0.1);
    border-bottom-style: solid;
}

/* Character Sheet Styles */
.char-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: center;
}

.char-portrait {
    width: 80px;
    height: 80px;
    background: var(--bg-panel);
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.char-main-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.char-title-input {
    background: transparent;
    border: none;
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent);
    width: 100%;
    border-bottom: 1px solid transparent;
    transition: border 0.2s;
}

.char-title-input:focus {
    outline: none;
    border-bottom: 1px solid var(--accent);
}

.char-sub-input {
    background: transparent;
    border: none;
    font-size: 1rem;
    color: var(--text-muted);
    font-style: italic;
    width: 100%;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.char-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.char-field label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
}

.char-field input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.3rem 0;
    font-family: var(--font-body);
}

.char-field input:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

/* Date Picker Dark Mode */
input[type="date"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.char-section {
    margin-bottom: 2rem;
}

.char-section label {
    display: block;
    margin-bottom: 0.8rem;
    color: var(--accent);
    font-family: var(--font-heading);
}

.char-section textarea,
.char-content-area {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100px;
}

.char-content-area {
    min-height: 300px;
}

.char-section textarea:focus,
.char-content-area:focus {
    outline: 1px solid var(--accent);
}

/* Modal and Utilities */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 400px;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-family: var(--font-heading);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.8rem;
    border-radius: 4px;
    color: var(--text-main);
    font-family: var(--font-body);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-secondary {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-secondary:hover {
    color: var(--text-main);
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 10000;
    width: 200px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    display: none;
    flex-direction: column;
    padding: 0.5rem 0;
}

.context-menu.visible {
    display: flex;
}

.context-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.context-item:hover {
    background: var(--accent);
    color: #000;
}

/* Link Selection Picker using same style as context menu but scrollable */
.link-picker {
    position: fixed;
    z-index: 10001;
    width: 250px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    display: none;
    /* controlled by JS */
}

.link-picker-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.link-picker-item:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent);
}