/* Strawberry AI: a focused scientific workspace layered over the shared portal shell. */
.ai-main {
    --ai-canvas: oklch(0.985 0.004 55);
    --ai-panel: oklch(0.965 0.008 55);
    --ai-hover: oklch(0.95 0.014 55);
    width: min(calc(100% - 40px), 1200px);
    margin: 0 auto;
    padding: 30px 0 52px;
    font-family: Inter, "Segoe UI", "Noto Sans", Arial, sans-serif;
}

.ai-main button,
.ai-main textarea,
.ai-main input,
.ai-main select {
    font-family: inherit;
}

.ai-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: 0 2px 22px;
    border-bottom: 1px solid var(--border);
}

.ai-heading-copy {
    min-width: 0;
}

.ai-heading h1 {
    max-width: none;
    margin: 0;
    font-size: 2rem;
    font-weight: 760;
    line-height: 1.16;
    letter-spacing: -0.03em;
    text-wrap: balance;
}

.ai-heading p {
    max-width: 68ch;
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.5;
    text-wrap: pretty;
}

.ai-service-state {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.ai-state-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
}

.ai-service-state.ready .ai-state-dot {
    background: var(--success);
}

.ai-service-state.unavailable .ai-state-dot {
    background: var(--error);
}

.ai-toolbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.ai-toolbar-actions {
    display: flex;
    align-items: center;
}

.ai-mode-note {
    min-width: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.ai-toolbar-actions {
    flex: 0 0 auto;
    gap: 8px;
}

.ai-access-toggle {
    min-height: 42px;
    display: inline-grid;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg);
    color: var(--ink);
    cursor: pointer;
}

.ai-access-toggle:hover,
.ai-access-toggle[aria-expanded="true"] {
    border-color: var(--border-strong);
    background: var(--ai-panel);
}

.ai-access-toggle-label {
    font-size: 0.87rem;
    font-weight: 730;
}

.ai-access-toggle-meta {
    max-width: 150px;
    color: var(--muted);
    font-size: 0.77rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-access-toggle.connected::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.ai-access-toggle.connected {
    grid-template-columns: auto auto auto;
}

.ai-access-panel {
    margin: 0 0 12px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--ai-panel);
}

.ai-quick-start {
    margin: 0 2px 18px;
    color: var(--ink);
    font-size: 0.875rem;
    line-height: 1.6;
}

.ai-quick-start p {
    margin: 0;
    text-wrap: pretty;
}

.ai-quick-start p + p {
    margin-top: 4px;
}

.ai-guide-panel {
    margin: 0 0 12px;
    padding: 18px 20px 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--ai-panel);
}

.ai-guide-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 28px;
    margin-top: 18px;
}

.ai-guide-grid > section + section {
    padding-left: 28px;
    border-left: 1px solid var(--border);
}

.ai-guide-grid h3 {
    margin: 0 0 10px;
    font-size: 0.91rem;
    line-height: 1.4;
}

.ai-mode-guide {
    margin: 0;
}

.ai-mode-guide div {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}

.ai-mode-guide dt {
    color: var(--berry);
    font-size: 0.8rem;
    font-weight: 760;
}

.ai-mode-guide dd,
.ai-api-steps,
.ai-guide-tip,
.ai-security-note {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.ai-mode-guide dd {
    margin: 0;
}

.ai-api-steps {
    margin: 0;
    padding-left: 20px;
}

.ai-api-steps li + li {
    margin-top: 5px;
}

.ai-guide-tip,
.ai-security-note {
    margin: 11px 0 0;
}

.ai-guide-tip a {
    font-weight: 700;
}

.ai-security-note {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.ai-access-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.ai-access-head h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.ai-access-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.ai-access-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 260px));
    gap: 8px;
    margin-top: 15px;
}

.ai-access-option {
    min-height: 60px;
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.ai-access-option:hover {
    border-color: var(--border-strong);
}

.ai-access-option.active {
    border-color: var(--berry);
    box-shadow: inset 3px 0 0 var(--berry);
}

.ai-access-option strong {
    font-size: 0.88rem;
}

.ai-access-option span {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.ai-key-settings {
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) minmax(190px, 1fr) minmax(240px, 1.5fr) auto;
    align-items: end;
    gap: 12px;
    margin-top: 15px;
}

.ai-field {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.ai-field label {
    color: var(--ink);
    font-size: 0.79rem;
    font-weight: 700;
}

.ai-field input,
.ai-field select {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    outline: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 0.87rem;
}

.ai-secret-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
}

.ai-secret-input input {
    border-radius: 8px 0 0 8px;
}

.ai-secret-input button {
    min-width: 54px;
    min-height: 42px;
    padding: 7px 9px;
    border: 1px solid var(--border-strong);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 680;
    cursor: pointer;
}

.ai-field input:focus,
.ai-field select:focus,
.ai-secret-input:focus-within input,
.ai-secret-input:focus-within button {
    border-color: var(--berry);
}

.ai-key-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-apply-key,
.ai-clear-key {
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 710;
    cursor: pointer;
    white-space: nowrap;
}

.ai-apply-key {
    border: 1px solid var(--berry);
    background: var(--berry);
    color: white;
}

.ai-clear-key {
    border: 0;
    background: transparent;
    color: var(--muted);
}

.ai-access-feedback {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.ai-access-toggle:focus-visible,
.ai-access-option:focus-visible,
.ai-apply-key:focus-visible,
.ai-clear-key:focus-visible,
.ai-secret-input button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--berry) 24%, transparent);
    outline-offset: 2px;
}

.ai-text-action,
.ai-panel-close {
    min-height: 40px;
    padding: 7px 11px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 680;
    cursor: pointer;
    transition: background-color 180ms ease-out, color 180ms ease-out;
}

.ai-text-action:hover,
.ai-panel-close:hover {
    background: var(--ai-hover);
    color: var(--ink);
}

.ai-workspace {
    min-height: 620px;
    height: calc(100vh - 278px);
    max-height: 760px;
    display: block;
    margin-top: 2px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--ai-canvas);
}

.ai-workspace.evidence-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
}

.ai-conversation {
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.ai-thread {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 34px clamp(24px, 5vw, 68px) 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.ai-empty {
    width: min(100%, 760px);
    margin: clamp(64px, 13vh, 122px) auto 0;
    text-align: center;
}

.ai-empty h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.55rem;
    font-weight: 740;
    line-height: 1.3;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.ai-empty p {
    margin: 9px auto 0;
    color: var(--muted);
    font-size: 0.96rem;
    line-height: 1.5;
}

.ai-prompts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 28px;
    border: 0;
}

.ai-prompts button {
    width: 100%;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--bg);
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 620;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: border-color 180ms ease-out, background-color 180ms ease-out, color 180ms ease-out;
    text-decoration: none;
}

.ai-prompts button::after {
    content: "\2192";
    flex: 0 0 auto;
    color: var(--berry);
    font-size: 1.05rem;
}

.ai-prompts button[hidden] {
    display: none;
}

.ai-prompts button:hover {
    padding: 13px 15px;
    border-color: var(--border-strong);
    background: var(--ai-panel);
    color: var(--berry);
}

.ai-message {
    width: min(100%, 800px);
    max-width: none;
    margin: 0 auto 30px;
}

.ai-message.user {
    width: fit-content;
    max-width: min(650px, 82%);
    margin-right: 0;
    margin-left: auto;
    padding: 13px 17px;
    border-radius: 14px 14px 4px 14px;
    background: var(--surface-strong);
}

.ai-message.assistant {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 13px;
}

.ai-assistant-mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--berry);
    color: var(--bg);
    font-size: 0.86rem;
    font-weight: 800;
}

.ai-message-content {
    min-width: 0;
}

.ai-message-head {
    min-height: 32px;
    display: flex;
    align-items: center;
    margin: 0 0 6px;
}

.ai-message-head strong {
    font-size: 0.92rem;
    font-weight: 750;
}

.ai-message-body {
    color: var(--ink);
    font-size: 0.98rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.ai-message-body p {
    max-width: 72ch;
    margin: 0 0 13px;
    text-wrap: pretty;
}

.ai-message-body p:last-child,
.ai-message-body ul:last-child {
    margin-bottom: 0;
}

.ai-message-body ul {
    max-width: 72ch;
    margin: 8px 0 15px;
    padding-left: 21px;
}

.ai-answer-table-wrap {
    max-width: 100%;
    margin: 10px 0 17px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.ai-answer-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    background: var(--bg);
    font-size: 0.84rem;
    line-height: 1.45;
}

.ai-answer-table th,
.ai-answer-table td {
    padding: 9px 11px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.ai-answer-table th {
    background: var(--ai-panel);
    color: var(--muted);
    font-weight: 720;
    white-space: nowrap;
}

.ai-answer-table td:first-child {
    color: var(--berry);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    white-space: nowrap;
}

.ai-answer-table tbody tr:last-child td {
    border-bottom: 0;
}

.ai-message.pending .ai-message-body {
    width: min(100%, 520px);
    min-height: 58px;
}

.ai-waiting {
    min-height: 54px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    color: var(--ink);
}

.ai-waiting > span:nth-child(2) {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.ai-waiting strong {
    font-size: 0.9rem;
    font-weight: 720;
}

.ai-waiting small,
.ai-waiting time {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.ai-waiting time {
    font-variant-numeric: tabular-nums;
}

.ai-waiting-mark {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 8px;
    background: var(--berry-soft);
}

.ai-waiting-mark i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--berry);
    animation: ai-thinking 1.1s ease-in-out infinite;
}

.ai-waiting-mark i:nth-child(2) { animation-delay: 140ms; }
.ai-waiting-mark i:nth-child(3) { animation-delay: 280ms; }

@keyframes ai-thinking {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.48; }
    35% { transform: translateY(-3px); opacity: 1; }
}

.ai-message.failed .ai-message-body {
    padding: 11px 13px;
    border-radius: 8px;
    background: var(--error-soft);
    color: var(--error);
}

.ai-inline-citation {
    padding: 1px 4px;
    border-radius: 4px;
    background: var(--berry-soft);
    font-family: var(--font-mono);
    font-size: 0.82em;
    text-decoration: underline;
    text-underline-offset: 0.16em;
    overflow-wrap: anywhere;
}

.ai-message-body code {
    padding: 1px 4px;
    border-radius: 4px;
    background: var(--berry-soft);
    font-family: var(--font-mono);
    font-size: 0.88em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ai-copy-answer {
    min-height: 34px;
    margin-top: 10px;
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
}

.ai-copy-answer:hover {
    background: var(--ai-hover);
    color: var(--ink);
}

.ai-answer-actions {
    max-width: 72ch;
    margin-top: 17px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.ai-result-context {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.78rem;
}

.ai-result-context code {
    color: var(--berry);
    font: 0.78rem/1.5 var(--font-mono);
}

.ai-composer {
    position: static;
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 0 clamp(18px, 3.5vw, 48px) 22px;
    padding: 10px 10px 10px 16px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--bg);
    z-index: auto;
    transition: border-color 180ms ease-out;
}

.ai-composer-access {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.ai-composer-access.exhausted {
    color: var(--berry);
    font-weight: 650;
}

.ai-composer-access .ai-text-action {
    min-height: 32px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ai-composer:focus-within {
    border-color: var(--berry);
}

.ai-composer textarea {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 48px;
    max-height: 164px;
    padding: 10px 2px 7px;
    resize: none;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 0.98rem;
    line-height: 1.5;
}

.ai-composer textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

.ai-composer-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-interaction-mode {
    flex: 0 0 auto;
    width: auto;
    min-width: 78px;
    min-height: 42px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--ai-panel);
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 720;
    cursor: pointer;
}

.ai-interaction-mode:hover {
    background: var(--ai-hover);
}

.ai-interaction-mode:focus-visible {
    border-color: var(--berry);
    outline: 3px solid color-mix(in srgb, var(--berry) 22%, transparent);
    outline-offset: 1px;
}

.ai-interaction-mode:disabled {
    cursor: wait;
    opacity: 0.62;
}

.ai-character-count {
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.ai-stop,
.ai-send {
    min-height: 42px;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 740;
    cursor: pointer;
}

.ai-stop {
    padding: 7px 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.ai-stop:hover {
    background: var(--ai-hover);
    color: var(--ink);
}

.ai-send {
    min-width: 66px;
    padding: 8px 15px;
    border: 0;
    background: var(--berry);
    color: var(--bg);
    transition: background-color 180ms ease-out, transform 180ms ease-out;
}

.ai-send:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.ai-send:active {
    transform: translateY(0);
}

.ai-send:disabled {
    cursor: wait;
    opacity: 0.62;
    transform: none;
}

.ai-evidence {
    min-width: 0;
    max-height: none;
    margin: 0;
    padding: 22px 20px 26px;
    overflow-y: auto;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--ai-panel);
}

.ai-evidence[hidden] {
    display: none;
}

.ai-evidence-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
}

.ai-evidence-head > div {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-evidence h2,
.ai-evidence h3,
.ai-evidence h4 {
    margin: 0;
}

.ai-evidence h2 {
    font-size: 1.06rem;
    font-weight: 760;
}

.ai-mode {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 730;
}

.ai-mode.ready {
    background: var(--success-soft);
    color: var(--success);
}

.ai-mode.working,
.ai-mode.limited {
    background: var(--warning-soft);
    color: var(--primary-dark);
}

.ai-panel-close {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 0.82rem;
}

.ai-evidence-section {
    padding: 17px 0;
    border-top: 1px solid var(--border);
}

.ai-evidence-section h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 750;
}

.ai-evidence-section h3 span {
    color: var(--muted);
    font-size: 0.8rem;
}

.ai-agent-plan ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: agent-step;
}

.ai-agent-plan li {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 7px;
    align-items: baseline;
    color: var(--ink);
    font-size: 0.84rem;
    counter-increment: agent-step;
}

.ai-agent-plan li::before {
    content: counter(agent-step);
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
}

.ai-agent-plan li > span {
    color: var(--success);
    font-size: 0.75rem;
}

.ai-agent-plan li > p {
    grid-column: 2 / -1;
    margin: -2px 0 0;
    color: var(--muted);
    line-height: 1.42;
}

.ai-rail-empty,
.ai-warning-list {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.ai-citation {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 9px;
    padding: 11px 0;
    border-top: 1px solid var(--border);
    scroll-margin-top: 90px;
}

.ai-citation:first-child,
.ai-tool:first-child {
    border-top: 0;
}

.ai-citation:target {
    border-radius: 8px;
    background: var(--berry-soft);
}

.ai-citation-index {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--berry-soft);
    color: var(--berry);
    font-size: 0.75rem;
    font-weight: 780;
}

.ai-citation h4 {
    font-size: 0.84rem;
    line-height: 1.45;
    text-wrap: pretty;
}

.ai-citation code {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.73rem;
    overflow-wrap: anywhere;
}

.ai-citation a {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.8rem;
    font-weight: 650;
}

.ai-tool {
    border-top: 1px solid var(--border);
}

.ai-tool summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.ai-tool summary strong {
    font-size: 0.84rem;
    overflow-wrap: anywhere;
}

.ai-tool pre {
    max-height: 270px;
    margin: 0 0 12px;
    padding: 10px;
    overflow: auto;
    border-radius: 7px;
    background: var(--ink);
    color: var(--bg);
    font: 0.72rem/1.55 var(--font-mono);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ai-module-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 7px;
    padding-bottom: 13px;
}

.ai-module-actions a,
.ai-module-actions button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: var(--bg);
    color: var(--berry);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    font-family: inherit;
    cursor: pointer;
}

.ai-module-actions a:hover,
.ai-module-actions button:hover {
    border-color: var(--berry);
    color: var(--primary-dark);
}

.ai-module-actions a.primary,
.ai-module-actions button.primary {
    border-color: var(--berry);
    background: var(--berry);
    color: var(--bg);
}

.ai-module-actions.answer {
    padding: 0;
}

.ai-download-control {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.ai-download-status {
    max-width: 52ch;
    color: var(--ink);
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.ai-module-actions button:disabled {
    border-color: var(--border-strong);
    background: var(--ai-panel);
    color: var(--ink);
    cursor: not-allowed;
}

.ai-module-actions button[aria-busy="true"] {
    cursor: progress;
}

.ai-module-actions button {
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: start;
}

.ai-module-actions.answer a,
.ai-module-actions.answer button {
    min-height: 36px;
    font-size: 0.8rem;
}

.ai-warning-list {
    padding-left: 18px;
}

.ai-warning-list li + li {
    margin-top: 7px;
}

.ai-rail-skeleton {
    display: grid;
    gap: 8px;
}

.ai-rail-skeleton span {
    height: 48px;
    border-radius: 7px;
    background: var(--surface-strong);
}

@keyframes ai-skeleton {
    to { background-position-x: -200%; }
}

@media (max-width: 900px) {
    .ai-key-settings {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-key-actions {
        align-self: end;
    }

    .ai-workspace.evidence-open {
        height: auto;
        max-height: none;
        display: grid;
        grid-template-columns: 1fr;
    }

    .ai-workspace.evidence-open .ai-conversation {
        min-height: 620px;
    }

    .ai-evidence {
        max-height: 480px;
        border-top: 1px solid var(--border);
        border-left: 0;
    }
}

@media (max-width: 680px) {
    .ai-main {
        width: min(calc(100% - 20px), 1200px);
        padding: 22px 0 34px;
    }

    .ai-heading {
        align-items: flex-start;
        gap: 14px;
        padding-bottom: 18px;
    }

    .ai-heading h1 {
        font-size: 1.55rem;
    }

    .ai-heading p {
        font-size: 0.9rem;
    }

    .ai-service-state {
        min-height: 34px;
        padding: 5px 9px;
        font-size: 0.78rem;
    }

    .ai-toolbar {
        min-height: 60px;
        gap: 10px;
    }

    .ai-mode-note {
        display: none;
    }

    .ai-text-action {
        padding-right: 7px;
        padding-left: 7px;
    }

    .ai-access-toggle-meta {
        max-width: 74px;
    }

    .ai-access-panel {
        padding: 16px;
    }

    .ai-guide-panel {
        padding: 16px;
    }

    .ai-guide-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .ai-guide-grid > section + section {
        padding: 18px 0 0;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .ai-access-options,
    .ai-key-settings {
        grid-template-columns: 1fr;
    }

    .ai-key-actions {
        flex-wrap: wrap;
    }

    .ai-interaction-mode,
    .ai-text-action,
    .ai-stop,
    .ai-send {
        min-height: 44px;
    }

    .ai-workspace {
        min-height: 590px;
        height: calc(100vh - 246px);
        margin: 2px 0 0;
        border: 1px solid var(--border);
        border-radius: 11px;
    }

    .ai-thread {
        padding: 28px 16px 20px;
    }

    .ai-empty {
        margin-top: 48px;
    }

    .ai-empty h2 {
        font-size: 1.28rem;
    }

    .ai-empty p {
        font-size: 0.9rem;
    }

    .ai-prompts {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 22px;
    }

    .ai-prompts button {
        min-height: 54px;
        font-size: 0.88rem;
    }

    .ai-message.user {
        max-width: 90%;
    }

    .ai-message.assistant {
        grid-template-columns: 29px minmax(0, 1fr);
        gap: 10px;
    }

    .ai-assistant-mark {
        width: 29px;
        height: 29px;
        border-radius: 8px;
    }

    .ai-composer {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        gap: 4px;
        margin: 0 10px 12px;
        padding: 8px 8px 8px 12px;
    }

    .ai-composer-actions {
        width: max-content;
        max-width: 100%;
        justify-self: end;
        gap: 6px;
    }

    .ai-interaction-mode {
        min-width: 72px;
        padding-right: 7px;
        padding-left: 7px;
    }

    .ai-composer textarea {
        width: 100%;
        min-height: 44px;
        font-size: 0.94rem;
    }

    .ai-send {
        min-width: 58px;
        padding-right: 12px;
        padding-left: 12px;
    }

    .ai-evidence {
        padding: 20px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-thread {
        scroll-behavior: auto;
    }

    .ai-message.pending .ai-message-body {
        animation: none;
    }

    .ai-waiting-mark i {
        animation: none;
        opacity: 0.8;
    }

    .ai-prompts button,
    .ai-text-action,
    .ai-panel-close,
    .ai-composer,
    .ai-send {
        transition: none;
    }
}
