* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: #f5f5f5;
    color: #1a1a1a;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #ffffff;
}

/* Header */
header {
    border-bottom: 1px solid #e0e0e0;
    padding: 16px;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    color: #10b981;
}

h1 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 13px;
    color: #666666;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.main-content.two-column {
    flex-direction: row;
}

.main-content.single-column {
    flex-direction: column;
}

/* Source Section */
.source-section {
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.two-column .source-section {
    flex: 1;
    height: 100%;
}

.single-column .source-section {
    flex: 0 0 auto;
    overflow: auto;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.button-group {
    display: flex;
    gap: 8px;
}

.icon-btn {
    padding: 6px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #f5f5f5;
    border-color: #999999;
}

.icon-btn svg {
    color: #1a1a1a;
}

/* Text Input */
.text-input {
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #1a1a1a;
    background: #f9f9f9;
    resize: none;
    transition: all 0.2s;
}

.text-input:focus {
    outline: none;
    border-color: #10b981;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Notion Selector */
.notion-selector {
    margin-bottom: 16px;
    border: 1px solid #10b981;
    border-radius: 6px;
    background: #f0fdf4;
    overflow: hidden;
}

.notion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #10b981;
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    opacity: 0.8;
}

.notion-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    justify-content: center;
    color: #059669;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #d1fae5;
    border-top-color: #059669;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.notion-list {
    max-height: 300px;
    overflow-y: auto;
}

.notion-item {
    padding: 12px;
    border-bottom: 1px solid #d1fae5;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 13px;
}

.notion-item:hover {
    background: #d1fae5;
}

.notion-item:last-child {
    border-bottom: none;
}

.notion-item-title {
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.notion-item-parent {
    font-size: 11px;
    color: #059669;
}

.card-edit-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-edit-textarea {
    flex: 1;
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    resize: vertical;
    background: #f9f9f9;
}

.card-edit-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    margin-top: 4px;
}

.card-edit-btn {
    padding: 8px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.card-edit-btn:hover {
    background: #f5f5f5;
}

.card-edit-btn.save {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.card-edit-btn.save:hover {
    background: #059669;
}

/* Interactive Display */
.interactive-display {
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #ffffff;
    overflow: auto;
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.5;
}

.interactive-display.empty {
    display: flex;
    align-items: center;
    color: #999999;
}

.clickable-sentence {
    cursor: pointer;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.clickable-sentence:hover {
    background-color: #dbeafe;
}

/* Markdown rendered content */
.interactive-display h1,
.interactive-display h2,
.interactive-display h3 {
    font-weight: 600;
    margin: 4px 0 0 0;
    font-size: 13px;
}

.interactive-display h1 {
    color: #10b981;
}

.interactive-display h2 {
    color: #2563eb;
}

.interactive-display h3 {
    color: #1a1a1a;
}

.interactive-display p {
    margin: 0;
    line-height: 1.5;
}

.interactive-display ul {
    margin: 4px 0 4px 20px;
    list-style-type: disc;
}

.interactive-display li {
    margin: 2px 0;
    line-height: 1.5;
}

.interactive-display strong {
    font-weight: 600;
    color: #1a1a1a;
}

.interactive-display em {
    font-style: italic;
}

.clickable-sentence.header-sentence {
    font-weight: 600;
    display: block;
    margin: 4px 0 0 0;
    color: inherit;
}

.clickable-sentence.header-sentence:hover {
    background-color: #e0e7ff;
}

/* Column Divider */
.column-divider {
    width: 16px;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.divider-handle {
    width: 8px;
    height: 24px;
    background: #d1d5db;
    border-radius: 9999px;
    transition: background-color 0.2s;
}

.column-divider:hover .divider-handle {
    background: #9ca3af;
}

/* Cards Section */
.cards-section {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.cards-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.cards-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cards-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.clear-btn {
    padding: 8px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: #f5f5f5;
    border-color: #999999;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: #666666;
}

.empty-icon {
    color: #d1d5db;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 16px;
    max-width: 400px;
}

.tip-box {
    background: #eff6ff;
    padding: 16px;
    border-radius: 6px;
    max-width: 400px;
}

.tip-box p {
    font-size: 12px;
    color: #1e40af;
    margin: 0;
}

/* Cards List */
.cards-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Cloze Card */
.cloze-card {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    transition: box-shadow 0.2s;
}

.cloze-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.card-content {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    user-select: none;
    font-size: 11px;
}

.token {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: all 0.1s;
    color: #1a1a1a;
    font-size: 11px;
}

.token:not(.clozed):hover {
    background: #f3f4f6;
}

/* Cloze levels with colors */
.token.clozed.level-1 { background: #fef08a; }
.token.clozed.level-2 { background: #bfdbfe; }
.token.clozed.level-3 { background: #bbf7d0; }
.token.clozed.level-4 { background: #fed7aa; }
.token.clozed.level-5 { background: #fecaca; }
.token.clozed.level-6 { background: #e9d5ff; }
.token.clozed.level-7 { background: #99f6e4; }
.token.clozed.level-8 { background: #fbcfe8; }

.token.selected {
    outline: 2px solid #60a5fa;
    outline-offset: 1px;
}

.copy-btn {
    padding: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s;
    margin-left: 8px;
}

.copy-btn:hover {
    color: #1a1a1a;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

/* Combine Button */
.combine-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2px 0;
}

.combine-btn button {
    width: 24px;
    height: 24px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.combine-btn button:hover {
    background: #f3f4f6;
    color: #1a1a1a;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-content.two-column {
        flex-direction: column;
    }

    .column-divider {
        display: none !important;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    h1 {
        font-size: 18px;
    }

    .subtitle {
        font-size: 12px;
    }

    .source-section,
    .cards-section {
        padding: 12px;
    }

    .token {
        font-size: 10px;
    }
}
