/* Ganak — the AI helper panel, sign-in dialog and "Fix with AI" buttons (web/js/app/ai.js). Uses app.css's tokens. */
.ai { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.ai-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex: none; }
.ai-head .sp, .ai-row .sp { flex: 1; }
.ai-tabs button { padding: 3px 9px; }
.ai-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.ai-pane { padding: 10px 12px 18px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.ai-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-hint { margin: 0; color: var(--text2); font-size: 12.5px; line-height: 1.5; }
.ai-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text2); cursor: pointer; }
.ai-check input { accent-color: var(--accent); margin: 0; }
.ai textarea { width: 100%; resize: vertical; font: 13px/1.45 var(--font); }
.ai .btn svg.i { width: 15px; height: 15px; }
.ai-out { display: flex; flex-direction: column; gap: 10px; }
.ai-out:empty { display: none; }
.ai-src { font-size: 11.5px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
.ai-src b, .ai-src code { text-transform: none; letter-spacing: 0; color: var(--text2); font-family: var(--mono); font-weight: 500; }
.ai-problem { font-weight: 650; color: var(--text); padding: 7px 10px; border-left: 3px solid var(--warn); background: rgba(251,191,36,.08); border-radius: 0 6px 6px 0; }
.ai-err { color: var(--bad); background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.35); padding: 7px 10px; border-radius: 7px; font-size: 12.5px; }
.ai-errcard { display: grid; gap: 5px; }
.ai-errtext { margin: 0; color: var(--bad); font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
.ai-meta { font-size: 11px; color: var(--text3); }
.ai-wait { display: flex; align-items: center; gap: 8px; color: var(--text2); font-size: 12.5px; padding: 4px 0; }
.ai-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--accent); animation: ai-spin .8s linear infinite; flex: none; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* answers (Markdown) and code */
.ai-md { line-height: 1.55; font-size: 13px; overflow-wrap: anywhere; }
.ai-md > :first-child { margin-top: 0; } .ai-md > :last-child { margin-bottom: 0; }
.ai-md p { margin: 6px 0; } .ai-md ul, .ai-md ol { margin: 6px 0; padding-left: 20px; }
.ai-md h1, .ai-md h2, .ai-md h3 { font-size: 14px; margin: 10px 0 4px; }
.ai-md code { font-family: var(--mono); font-size: .92em; background: var(--panel3); padding: 1px 5px; border-radius: 4px; }
.ai-md a { color: var(--accent2); }
.ai-md table { border-collapse: collapse; } .ai-md td, .ai-md th { border: 1px solid var(--line2); padding: 3px 8px; }
.ai-code { border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; background: var(--bg2); margin: 6px 0; }
.ai-code pre { margin: 0; padding: 9px 11px; font: var(--code-size)/1.5 var(--mono); white-space: pre; overflow: auto; max-height: 340px; color: var(--text); }
.ai-code.small pre { max-height: 240px; font-size: 12.5px; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line); background: var(--panel2); }
.ai-actions .btn svg.i { width: 13px; height: 13px; }

/* chat */
.ai-chatpane { flex: 1; padding-bottom: 10px; }
.ai-chat { flex: 1; min-height: 120px; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
.ai-msg.user { align-self: flex-end; max-width: 88%; }
.ai-msg.user .ai-bubble { background: var(--sel); border: 1px solid rgba(56,189,248,.35); padding: 7px 10px; border-radius: 12px 12px 3px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.assistant { align-self: stretch; padding: 2px 2px 2px 10px; border-left: 2px solid var(--line2); display: grid; gap: 4px; }
.ai-intro p { margin: 0 0 10px; color: var(--text2); line-height: 1.5; }
.ai-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ai-suggest .btn { height: auto; min-height: 26px; padding: 4px 10px; white-space: normal; text-align: left; line-height: 1.35; }
.ai-chatform { display: flex; gap: 6px; align-items: flex-end; }
.ai-chatform textarea { flex: 1; min-height: 40px; max-height: 160px; }
.ai-send.stop { background: var(--panel3); border-color: var(--line2); color: var(--text); }

/* signed out / not available */
.ai-gate { padding: 26px 18px; text-align: center; color: var(--text2); display: flex; flex-direction: column; align-items: center; gap: 4px; line-height: 1.55; }
.ai-gate > svg.i { width: 30px; height: 30px; color: var(--accent); margin-bottom: 6px; }
.ai-gate p { margin: 0 0 8px; max-width: 360px; }
.ai-gate .ai-row { justify-content: center; }

/* the month's use */
.ai-foot { flex: none; border-top: 1px solid var(--line); padding: 5px 10px; }
.ai-meter { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text2); }
.ai-meter .bar { flex: 1; height: 5px; border-radius: 3px; background: var(--panel3); overflow: hidden; }
.ai-meter .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.ai-meter.low .bar i { background: var(--warn); }
.ai-usage { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* the dock tab, the topbar button, the Command Window button */
.ai-top { color: var(--accent); }
.ai-top:hover { color: var(--accent2); }
.ptab.ai-ptab svg.i { color: var(--accent); }
.ai-fixbar { margin-top: 4px; }
.ai-fixbtn { display: inline-flex; align-items: center; gap: 5px; font: 12px/1 var(--font); height: 24px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; }
.ai-fixbtn:hover { border-color: var(--accent); color: var(--accent2); }
.ai-fixbtn svg.i { width: 13px; height: 13px; color: var(--accent); }

/* sign-in dialog */
.modal.ai-signin { width: min(420px, calc(100vw - 32px)); }
.modal.ai-signin .seg { justify-self: start; }
.modal input[type=email], .modal input[type=password] { background: var(--bg2); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 8px; min-width: 0; color: var(--text); }
.modal input[type=email]:focus, .modal input[type=password]:focus { outline: none; border-color: var(--accent); }
.modal.ai-signin small.dim { line-height: 1.5; }
