:root {
    --bg-main: #0A0A0A;
    --bg-surface: #171717;
    --bg-surface-elevated: #262626;
    --text-primary: #FAFAFA;
    --text-secondary: #A3A3A3;
    --primary: #F59E0B;
    --primary-hover: #D97706;
    --danger: #EF4444;
    --success: #10B981;
    --border: #333333;
    
    --focus-color: #F59E0B;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    max-height: 900px;
    background-color: var(--bg-surface);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    text-align: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.view.active {
    opacity: 1;
    pointer-events: all;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn.primary {
    background-color: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background-color: #333;
}

.btn.full-width {
    width: 100%;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.primary-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

.primary-icon:active {
    transform: scale(0.95);
}

/* Setup View */
#text-input {
    width: 100%;
    flex: 1;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    margin-bottom: 1rem;
    min-height: 200px;
}

#text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.sample-texts {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sample-texts button {
    flex: 1;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

/* Reader View */
#reader-view {
    padding: 0;
}

.reader-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.progress-container {
    flex: 1;
    height: 8px;
    background-color: var(--bg-surface-elevated);
    border-radius: 4px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary);
    transition: width 0.1s linear;
}

.stats {
    font-family: monospace;
    color: var(--text-secondary);
}

.reader-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
}

/* Guide Lines */
.reader-display::before, .reader-display::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 2px;
    height: 30px;
    background-color: var(--border);
    transform: translateX(-50%);
}

.reader-display::before {
    top: 20%;
}

.reader-display::after {
    bottom: 20%;
}

#word-container {
    font-size: 48px; /* Controlled by JS */
    font-weight: 500;
    letter-spacing: 1px;
    text-align: center;
    white-space: nowrap;
    display: flex;
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
    width: 100%;
}

/* The crucial part: center alignment based on the ORP letter */
#word-container .before {
    display: inline-block;
    width: 50%;
    text-align: right;
}

#word-container .orp {
    display: inline-block;
    color: var(--focus-color);
}

#word-container .after {
    display: inline-block;
    width: 50%;
    text-align: left;
}


.reader-controls {
    padding: 1.5rem;
    background-color: var(--bg-surface-elevated);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.playback-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.adjustments {
    display: flex;
    gap: 2rem;
}

.adjustment-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.adjustment-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 70px;
}

/* Quiz View */
.quiz-item {
    background-color: var(--bg-surface-elevated);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.quiz-item p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.quiz-input {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 4px;
}

.quiz-input:focus {
    outline: none;
    border-color: var(--primary);
}

.quiz-result-item {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.quiz-result-item.correct { color: var(--success); }
.quiz-result-item.incorrect { color: var(--danger); }

.mt-4 { margin-top: 1rem; }
