.composer {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.secondary-btn {
    border: 1px solid var(--border-strong);
    background: var(--field-bg);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color 0.15s, color 0.15s;
}

.secondary-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.button-glyph {
    width: 17px;
    height: 17px;
    display: inline-block;
    flex: 0 0 auto;
    background: currentColor;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: contain;
}

.composer-fields {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 18px;
    padding: 22px 20px 10px;
}

.field { display: flex; flex-direction: column; position: relative; }

.field > label {
    position: absolute;
    top: -8px;
    left: 10px;
    z-index: 1;
    max-width: calc(100% - 20px);
    padding: 0 5px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: linear-gradient(var(--surface-solid) 50%, var(--field-bg) 50%);
    border-radius: 4px;
    pointer-events: none;
}

.field:focus-within > label { color: var(--accent); }

.field.has-error > label { color: var(--error-text); }

.field.has-error .form-input { border-color: var(--error-text); }

.form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    background: var(--field-bg);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 15px;
    font-family: var(--font-ui);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

.form-input[readonly] {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
    cursor: default;
}

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

textarea.form-input { resize: none; }

.message-input {
    resize: none;
    min-height: calc(4lh + 22px);
    field-sizing: content;
    max-height: calc(12lh + 22px);
    line-height: 1.4;
}

.composer-footer {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding: 12px 20px 18px;
    background: var(--surface-solid);
    border-top: 1px solid var(--border-color);
}

.primary-btn {
    width: 100%;
    border: 0;
    padding: 14px 20px;
    border-radius: 10px;
    color: var(--accent-ink);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background: var(--accent);
    transition: background 0.15s, opacity 0.15s;
}

.primary-btn:hover:not(:disabled) { background: var(--accent-strong); }

.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn:focus-visible,
.secondary-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.composer-error {
    margin-bottom: 11px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.83rem;
    background: rgba(244, 67, 54, 0.14);
    color: #e23b2c;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

html.dark-mode .composer-error { color: #ff9a8f; }

.composer-note { margin-bottom: 10px; font-size: 13px; color: var(--text-secondary); text-align: center; }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-left-color: #fff;
    border-radius: 50%;
    animation: composer-spin 0.8s linear infinite;
}

.spinner.dark { border: 2px solid var(--border-strong); border-left-color: var(--text-primary); }

@keyframes composer-spin { to { transform: rotate(360deg); } }

.files-clear {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.files-clear span {
    width: 15px;
    height: 15px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 7h16m-10 4v6m4-6v6M6 7l1 14h10l1-14M9 7V4h6v3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.files-clear:hover { color: var(--accent); border-color: var(--accent); }

.files-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.files-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--field-bg);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.files-add-btn:hover { border-color: var(--accent); color: var(--accent); }

.files-add-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.files-add-btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }

.is-empty .files-add-btn { min-height: 48px; padding: 10px 22px; font-size: 15px; }

.btn-glyph {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex: 0 0 auto;
    background: currentColor;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: contain;
}

.upload-glyph {
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 15V3m0 0 4 4m-4-4-4 4M5 15v4h14v-4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.folder-glyph {
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7h7l2 3h9v9H3V7Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tree-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    opacity: 0.72;
    transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    line-height: 1;
}

.tree-btn span {
    width: 13px;
    height: 13px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 6 12 12M18 6 6 18' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.tree-btn:hover {
    opacity: 1;
    color: var(--accent);
    background: rgba(17, 183, 170, 0.12);
    border-color: rgba(17, 183, 170, 0.24);
}

.tree-btn.text {
    width: auto;
    min-width: 28px;
    padding: 0 10px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.tree-btn:disabled { cursor: not-allowed; opacity: 0.4; }
.tree-btn.is-busy { opacity: 1; color: var(--accent); }
.download-glyph,
.tree-btn .download-glyph {
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3v12m0 0 4-4m-4 4-4-4M5 15v4h14v-4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.hero-copy {
    display: grid;
    transition: grid-template-rows 0.35s ease, opacity 0.25s ease;
}
.collapse-inner { min-height: 0; overflow: hidden; }

.hero-copy { grid-template-rows: 1fr; opacity: 1; }

.has-files .hero-copy { grid-template-rows: 0fr; opacity: 0; }

.hero-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(38px, 3.9vw, 64px);
    line-height: 1.04;
    letter-spacing: -0.03em;
    font-weight: 700;
    color: var(--hero-ink);
    text-wrap: balance;
}

.hero-sub {
    margin: 22px 0 0;
    max-width: 30em;
    font-size: 18px;
    line-height: 1.55;
    color: var(--hero-ink);
    text-wrap: pretty;
}

@media (max-width: 1100px) {
    .hero-title { font-size: clamp(32px, 3.6vw, 44px); }
}

@media (max-width: 820px) {
    .hero-title { font-size: 32px; }
    .hero-sub { font-size: 16px; margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .hero-copy { transition: none; }
}

.files-text-btn {
    height: 30px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}
.files-text-btn:hover { color: var(--accent); background: rgba(17, 183, 170, 0.08); }
.files-text-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(6, 24, 30, 0.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.confirm-dialog {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: 16px;
    background: var(--surface-solid);
    border: 1px solid var(--border-color);
    box-shadow: 0 24px 60px var(--shadow-color);
    color: var(--text-primary);
}

.confirm-dialog h2 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
}

.confirm-dialog p {
    margin: 0 0 22px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-cancel,
.confirm-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.confirm-cancel {
    border: 1px solid var(--border-strong);
    background: var(--field-bg);
    color: var(--text-primary);
}
.confirm-cancel:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.confirm-danger {
    border: 1px solid var(--error-text);
    background: var(--error-text);
    color: #fff;
}
.confirm-danger:hover:not(:disabled) { filter: brightness(0.92); }

.confirm-cancel:disabled,
.confirm-danger:disabled { opacity: 0.6; cursor: not-allowed; }

.confirm-cancel:focus,
.confirm-danger:focus { outline: none; }
.confirm-cancel:focus-visible { border-color: var(--accent); color: var(--accent); }
.confirm-danger:focus-visible { filter: brightness(0.92); }

.confirm-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.confirm-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.confirm-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.confirm-primary:focus { outline: none; }
.confirm-primary:focus-visible { background: var(--accent-strong); }

.confirm-dialog .field { margin: 0 0 16px; }
.confirm-dialog .dialog-error { margin: -6px 0 14px; color: var(--error-text); font-size: 14px; }

.empty-state {
    text-align: center;
    padding: clamp(42px, 5vw, 72px) 24px;
    border: 1px dashed rgba(14, 42, 49, 0.22);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 16px 38px rgba(11, 38, 46, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.empty-state h3 {
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    margin: 0;
    color: var(--text-secondary);
}

html.dark-mode .empty-state {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.16);
}

.btn-icon {
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.45rem 0.75rem;
    border-radius: 9px;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-icon:hover:not(:disabled) {
    background: rgba(17, 183, 170, 0.08);
    border-color: rgba(17, 183, 170, 0.22);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon.delete:hover:not(:disabled) {
    background: rgba(255, 70, 70, 0.1);
    border-color: rgba(255, 70, 70, 0.24);
    color: #e23b2c;
}
html.dark-mode .btn-icon.delete:hover:not(:disabled) { color: #ff9a8f; }

.action-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--error-text);
    color: var(--error-text);
    font-size: 14px;
}
.action-error button {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 15px;
    cursor: pointer;
    padding: 0 4px;
}
