.modal-input,
.modal-select,
.subtask-input,
.editor-textarea,
.notes-textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 12px;
    outline: none;
    transition: 0.18s ease;
}

.modal-input,
.modal-select,
.notes-textarea {
    padding: 0.65rem 0.8rem;
}

.action-btn:hover,
.modal-close:hover,
.subtask-delete:hover,
.subtask-toggle:hover {
    border-color: rgba(168, 85, 247, 0.35);
    background: rgba(168, 85, 247, 0.1);
}

.modal-input:focus,
.modal-select:focus,
.subtask-input:focus,
.editor-textarea:focus,
.notes-textarea:focus {
    border-color: rgba(168, 85, 247, 0.65);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.14);
}

.action-btn {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 0.7rem 0.95rem;
    cursor: pointer;
    transition: 0.18s ease;
}

.action-btn.primary {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.28), rgba(59, 130, 246, 0.24));
    border-color: rgba(168, 85, 247, 0.38);
}

.action-btn.danger {
    color: #ffd7d7;
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.08);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    background: var(--bg-overlay, rgba(6, 7, 11, 0.74));
    backdrop-filter: blur(10px);
}

.modal-overlay.active {
    display: block;
}

.modal {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: linear-gradient(180deg, rgba(19, 21, 31, 0.99), rgba(10, 12, 19, 0.99));
}

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

.modal-title-wrap {
    min-width: 0;
}

.modal-title {
    margin: 0;
    font-size: 1.4rem;
}

.modal-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.75rem;
}

.modal-close {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.modal-body {
    min-height: 0;
    overflow: auto;
    padding: 1.2rem;
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.95fr);
    gap: 1.1rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    background: rgba(10, 12, 19, 0.82);
}

.panel {
    border: 1px solid var(--border);
    background: var(--bg-panel, rgba(255, 255, 255, 0.035));
    border-radius: 20px;
    padding: 1rem;
    min-width: 0;
}

.panel-title {
    margin: 0 0 0.85rem;
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.editor-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.modal-field label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.editor-tabs {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}

.editor-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
}

.editor-tab.active {
    color: var(--text-primary);
    background: rgba(168, 85, 247, 0.16);
}

.editor-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.9rem;
}

.editor-shell.preview-only .editor-pane.write-pane,
.editor-shell.write-only .editor-pane.preview-pane {
    display: none;
}

.editor-shell.preview-only,
.editor-shell.write-only {
    grid-template-columns: minmax(0, 1fr);
}

.editor-pane {
    min-width: 0;
}

.editor-textarea,
.notes-textarea {
    width: 100%;
    resize: vertical;
}

.editor-textarea {
    min-height: 400px;
    padding: 1rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
}

.notes-textarea {
    min-height: 120px;
}

.markdown-preview {
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    overflow: auto;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.markdown-preview p,
.markdown-preview li {
    color: var(--text-secondary);
}

.markdown-preview code {
    padding: 0.12rem 0.35rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
}

.markdown-preview pre {
    padding: 0.9rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    overflow-x: auto;
}

.markdown-preview blockquote {
    margin: 0;
    padding-left: 1rem;
    border-left: 3px solid rgba(168, 85, 247, 0.35);
    color: var(--text-secondary);
}

.tag-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.tag-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.62rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.tag-option input {
    display: none;
}

.tag-option.active {
    background: rgba(168, 85, 247, 0.16);
    color: #f1e5ff;
    border-color: rgba(168, 85, 247, 0.28);
}

.stage-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.stage-pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stage-pill:hover {
    border-color: rgba(168, 85, 247, 0.45);
    background: rgba(168, 85, 247, 0.12);
    color: var(--text-primary);
}

.stage-pill.selected {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.28), rgba(99, 102, 241, 0.22));
    border-color: rgba(168, 85, 247, 0.8);
    color: #f5f3ff;
    font-weight: 700;
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.18), 0 10px 24px rgba(76, 29, 149, 0.22);
}

.star-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.star {
    border: none;
    background: transparent;
    padding: 0.1rem;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: rgba(148, 163, 184, 0.5);
    transition: transform 0.15s ease, color 0.15s ease, filter 0.15s ease;
}

.star:hover {
    transform: scale(1.08);
}

.star.filled,
.star-rating.is-hovering .star.preview {
    color: #f5c451;
    filter: drop-shadow(0 0 8px rgba(245, 196, 81, 0.18));
}

.star-rating.is-hovering .star {
    color: rgba(148, 163, 184, 0.38);
}

.form-hidden-input {
    display: none;
}

.subtask-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.subtask-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.55rem;
    align-items: center;
    padding: 0.72rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
}

.subtask-row.done .subtask-toggle {
    text-decoration: line-through;
    color: var(--text-dim);
}

.subtask-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.subtask-toggle {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 0.2rem 0.35rem;
    border-radius: 10px;
    cursor: pointer;
}

.subtask-delete {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-dim);
    border-radius: 10px;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

.subtask-add {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.empty-note {
    color: var(--text-dim);
    font-size: 0.88rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1080px) {
    .modal-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .editor-shell {
        grid-template-columns: 1fr;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }

    .editor-meta-grid {
        grid-template-columns: 1fr;
    }
}
