:root {
    --bg-color: #080809;
    --panel-color: #141416;
    --panel-soft: #1b1b1f;
    --border-color: rgba(255, 255, 255, 0.12);
    --primary-color: #ff7a1a;
    --text-main: #f6f6f7;
    --text-muted: #9a9aa1;
    --success-color: #37d67a;
    --warning-color: #ffd45a;
    --error-color: #ff5548;
    --shadow: 0 14px 38px rgba(0, 0, 0, 0.36);
    --task-scroll-tail: max(104px, calc(env(safe-area-inset-bottom) + 86px));
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    background:
        linear-gradient(180deg, rgba(255, 122, 26, 0.08), transparent 42%),
        var(--bg-color);
    color: var(--text-main);
}

button,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-container {
    width: min(100%, 520px);
    height: 100dvh;
    margin: 0 auto;
    padding: 14px 12px max(14px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.fixed-workbench {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.app-header h1 {
    color: var(--primary-color);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
}

.app-header h1 span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.cache-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    display: grid;
    place-items: center;
}

.status-panel {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    min-width: 0;
}

.status-pill {
    min-width: 0;
    height: 25px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 800;
}

.pill-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex: 0 0 auto;
}

.status-pill.online .status-dot,
.status-pill.success .status-dot,
.llm-pill.has-response .status-dot {
    background: var(--success-color);
    box-shadow: 0 0 9px rgba(55, 214, 122, 0.65);
}

.llm-pill.waiting .status-dot {
    background: var(--warning-color);
    box-shadow: 0 0 9px rgba(255, 212, 90, 0.65);
}

.llm-pill.read .status-dot {
    background: var(--text-muted);
    box-shadow: none;
}

.status-pill.warning .status-dot {
    background: var(--warning-color);
    box-shadow: 0 0 9px rgba(255, 212, 90, 0.65);
}

.status-pill.failed .status-dot,
.status-pill.queued .status-dot {
    background: var(--error-color);
    box-shadow: 0 0 9px rgba(255, 85, 72, 0.65);
}

.status-pill.syncing .status-dot {
    background: var(--primary-color);
    box-shadow: 0 0 9px rgba(255, 122, 26, 0.65);
}

.input-panel,
.tasks-panel,
.task-modal-card {
    background: rgba(20, 20, 22, 0.94);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.input-panel {
    padding: 12px;
    display: grid;
    gap: 10px;
}

.text-input-wrapper {
    display: grid;
    grid-template-columns: 1fr 46px;
    gap: 9px;
}

.text-input-box {
    min-height: 70px;
    width: 100%;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #0f0f11;
    color: var(--text-main);
    outline: none;
    padding: 12px 13px;
    line-height: 1.4;
}

.text-input-box:focus,
.task-modal-edit-input:focus {
    border-color: rgba(255, 122, 26, 0.72);
}

.text-input-box::placeholder {
    color: var(--text-muted);
}

.send-text-btn {
    width: 46px;
    border: 1px solid rgba(255, 122, 26, 0.72);
    border-radius: 12px;
    background: rgba(255, 122, 26, 0.08);
    color: var(--primary-color);
    display: grid;
    place-items: center;
}

.send-icon {
    width: 22px;
    height: 22px;
}

.voice-ui-wrapper {
    min-height: 90px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--panel-soft);
    display: grid;
    grid-template-columns: 1fr 170px;
    align-items: center;
    gap: 12px;
    padding: 10px;
    position: relative;
}

.record-btn,
.control-btn {
    border-radius: 50%;
    border: 1px solid rgba(255, 122, 26, 0.72);
    background: rgba(255, 122, 26, 0.08);
    color: var(--primary-color);
    font-weight: 800;
}

.record-btn {
    width: 92px;
    height: 92px;
    justify-self: end;
}

.record-btn-text {
    font-size: 13px;
}

.recording-controls {
    display: flex;
    gap: 8px;
    justify-self: end;
}

.control-btn {
    width: 64px;
    height: 64px;
    font-size: 11px;
}

.btn-pause {
    border-color: var(--border-color);
    background: transparent;
    color: var(--text-muted);
}

.btn-pause.paused {
    border-color: rgba(55, 214, 122, 0.55);
    color: var(--success-color);
}

.record-hint {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.35;
    padding-left: 2px;
}

.wave-visualizer {
    position: absolute;
    left: 14px;
    bottom: 12px;
    height: 18px;
    display: none;
    align-items: center;
    gap: 4px;
}

.wave-visualizer.active {
    display: flex;
}

.bar {
    width: 3px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 2px;
    animation: wave 0.8s infinite alternate;
}

.bar:nth-child(2) { animation-delay: 0.1s; }
.bar:nth-child(3) { animation-delay: 0.2s; }
.bar:nth-child(4) { animation-delay: 0.3s; }
.bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    from { transform: scaleY(0.5); }
    to { transform: scaleY(1.8); }
}

.input-footer {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.llm-checkbox-container {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-weight: 800;
}

.llm-custom-checkbox {
    width: 18px;
    height: 18px;
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: grid;
    place-items: center;
}

.llm-custom-checkbox input {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.llm-checkmark {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 2px;
    opacity: 0;
}

.llm-custom-checkbox input:checked ~ .llm-checkmark {
    opacity: 1;
}

.llm-pill {
    width: auto;
    color: var(--text-muted);
}

.tasks-panel {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.tasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex: 0 0 auto;
}

.tasks-title-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.tasks-header h2 {
    font-size: 18px;
    color: rgba(246, 246, 247, 0.68);
}

.tasks-count-pill {
    color: var(--primary-color);
    border: 1px solid rgba(255, 122, 26, 0.72);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.3;
}

.queue-count-pill {
    max-width: 170px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-modal-actions button {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
}

.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 2px;
    flex: 0 0 auto;
}

.category-tab {
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
}

.category-tab.active {
    color: var(--primary-color);
    border-color: rgba(255, 122, 26, 0.68);
    background: rgba(255, 122, 26, 0.08);
}

.tasks-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: var(--task-scroll-tail);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 2px var(--task-scroll-tail) 0;
}

.task-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #101012;
    padding: 12px;
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: center;
    gap: 10px;
}

.task-checkbox-container {
    width: 20px;
    height: 20px;
    position: relative;
}

.task-checkbox-container input {
    position: absolute;
    opacity: 0;
}

.checkmark {
    position: absolute;
    inset: 0;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.task-checkbox-container input:checked ~ .checkmark {
    border-color: var(--primary-color);
    background: rgba(255, 122, 26, 0.12);
}

.task-checkbox-container input:checked ~ .checkmark::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--primary-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-text {
    font-size: 14px;
    line-height: 1.35;
    color: rgba(246, 246, 247, 0.76);
    overflow-wrap: anywhere;
    cursor: pointer;
}

.task-item.completed .task-text {
    color: var(--text-muted);
    text-decoration: line-through;
}

.task-category-badge {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    padding: 4px 6px;
}

.empty-state {
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    padding: 24px 12px;
    text-align: center;
    font-size: 13px;
}

.task-modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.76);
    z-index: 1000;
}

.task-modal-overlay.show {
    display: flex;
}

.task-modal-card {
    width: min(100%, 420px);
    padding: 16px;
}

.llm-modal-card .task-modal-header {
    margin-bottom: 10px;
}

.llm-modal-card .close-modal-btn {
    display: none;
}

.task-modal-header,
.task-modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.task-modal-header {
    margin-bottom: 12px;
}

.close-modal-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
}

.task-modal-edit-input {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    outline: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #0f0f11;
    color: var(--text-main);
    padding: 12px;
    margin-bottom: 12px;
}

.btn {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    font-weight: 800;
}

.btn-success {
    border-color: rgba(55, 214, 122, 0.55);
    color: var(--success-color);
}

.llm-modal-card {
    max-height: min(78vh, 560px);
    display: flex;
    flex-direction: column;
}

.llm-modal-content {
    min-height: 150px;
    max-height: 420px;
    overflow-y: auto;
    color: var(--text-main);
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #0f0f11;
    padding: 12px;
    margin-bottom: 12px;
}

@media (max-height: 720px) {
    .text-input-box {
        min-height: 58px;
    }

    .voice-ui-wrapper {
        min-height: 78px;
    }

    .record-btn {
        width: 80px;
        height: 80px;
    }

    .control-btn {
        width: 58px;
        height: 58px;
    }
}

@media (max-width: 420px) {
    .app-container {
        padding-inline: 10px;
    }

    .status-panel {
        gap: 4px;
    }

    .status-pill {
        padding: 0 5px;
        font-size: 10px;
    }

    .voice-ui-wrapper {
        grid-template-columns: 1fr 150px;
    }
}
