/* Writer */
.writer-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.fragments-area {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-y: auto;
    position: relative;
    max-height: calc(100vh - 200px);
}

/* Card View */
.view-cards .cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem;
}

.fragment-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    cursor: grab;
}

.fragment-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow-color);
}

.fragment-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.fragment-card.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.fragment-card.link-mode {
    cursor: pointer;
    border: 2px dashed var(--accent-color);
}

.fragment-card.link-mode:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.fragment-card.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.fragment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1rem 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.fragment-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fragment-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.fragment-priority {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.fragment-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.fragment-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

.fragment-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.fragment-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.fragment-btn.delete-btn:hover {
    background: var(--error-color);
}

.fragment-content {
    flex: 1;
    padding: 0 1rem;
}

.fragment-card textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    resize: none;
    min-height: 80px;
    padding: 0.5rem 0;
    line-height: 1.5;
}

.fragment-card textarea:focus {
    outline: none;
}

.fragment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

.fragment-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
}

.tag {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Timeline View */
.view-timeline .timeline-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
}

.timeline-marker {
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.timeline-header h4 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1rem;
}

.timeline-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

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

.btn-sm.delete:hover {
    background: var(--error-color);
}

.fragment-preview {
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.timeline-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.timeline-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Web View */
.web-view-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    text-align: center;
    color: var(--text-secondary);
}

.web-view-placeholder h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Writer Sidebar */
.writer-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fragment-inspector, .writing-prompts {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 300px;
}

.fragment-inspector h3, .writing-prompts h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.inspector-field {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.inspector-field label {
    color: var(--text-secondary);
    font-weight: 500;
}

.current-prompt {
    text-align: center;
}

.current-prompt p {
    font-style: italic;
    color: var(--primary-color);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.current-prompt button {
    margin: 0 0.25rem;
}

/* Link mode active state */
#link-fragments.active {
    background: var(--accent-color);
    color: white;
}