*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon rect { fill: currentColor; stroke: none; }

/* Düzen ---------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.sidebar-head { padding: 20px 20px 8px; }
.sidebar-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wordmark { font-size: 22px; font-weight: 650; letter-spacing: 0.02em; }
.wordmark::before {
  content: ''; display: inline-block; width: 24px; height: 24px; margin-right: 10px; border-radius: 7px;
  background: url('/favicon.svg') center / cover no-repeat; vertical-align: -5px;
}
.badge {
  display: inline-block; padding: 2px 9px; border: 1px solid var(--line-strong); border-radius: 999px;
  font: 600 11.5px/1.5 var(--mono); color: var(--muted); letter-spacing: 0.02em;
}
.badge-demo { color: var(--amber); background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.badge-readonly { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.sidebar-body > .mode-note-readonly { border-left-color: var(--accent); background: var(--accent-soft); }
.access-screen { display: flex; flex-direction: column; gap: 14px; max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.access-form { display: flex; flex-direction: column; gap: 10px; }
.access-input { min-height: 44px; width: 100%; }
.mode-note { margin: 6px 20px 0; padding: 0; color: var(--muted); font-size: 13px; }
.sidebar-body > .mode-note { margin: 0; padding: 10px 12px; border-left: 2px solid var(--amber); background: var(--amber-soft); border-radius: 0 6px 6px 0; }
.btn.drawer-toggle { display: none; }

.side-section { display: flex; flex-direction: column; gap: 10px; }
.side-title, .field-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.side-hint { font-size: 12.5px; color: var(--faint); }
.project-list { display: flex; flex-direction: column; gap: 4px; }
.project-empty { color: var(--muted); font-size: 14px; }
.project {
  display: flex; gap: 11px; align-items: flex-start; width: 100%; text-align: left; cursor: pointer;
  padding: 9px 11px; background: transparent; border: 1px solid transparent; border-radius: 8px;
}
.project:hover { background: var(--surface); }
.project[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent-line); }
.project-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.project-name { font-weight: 600; overflow-wrap: anywhere; }
.project-meta { display: flex; flex-wrap: wrap; column-gap: 8px; font-size: 12.5px; color: var(--muted); }
.project-status { color: var(--text); }
.dot { flex: none; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--faint); }
.dot[data-status='running'] { background: var(--green); }
.dot[data-status='failed'] { background: var(--red); }
.dot[data-status='crash_loop'] { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 28%, transparent); }
.dot[data-status='building'] { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.dot[data-status='stopped'] { background: transparent; border: 2px solid var(--faint); }

.select, .input {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px;
}
.select { min-height: 40px; }
.lang-block { display: flex; flex-direction: column; gap: 8px; }
.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.lang-btn { min-width: 52px; min-height: 36px; padding: 0 14px; background: transparent; border: 0; cursor: pointer; font-weight: 600; color: var(--muted); }
.lang-btn + .lang-btn { border-left: 1px solid var(--line-strong); }
.lang-btn[aria-pressed='true'] { background: var(--fill); color: var(--accent-ink); }

/* Düğmeler ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid transparent; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--fill); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--fill-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--muted); }
.btn-block { width: 100%; }

/* Ana alan ---------------------------------------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 28px 24px 12px; display: flex; flex-direction: column; gap: 22px;
  scroll-behavior: smooth;
}
.messages > * { width: 100%; max-width: var(--col); margin-inline: auto; }
.messages:focus-visible { outline-offset: -3px; }

.empty { margin-top: 8vh; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty-art { width: min(300px, 70%); height: auto; filter: drop-shadow(0 12px 40px var(--glow)); }
.empty-title { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.empty-body { max-width: 52ch; color: var(--muted); }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.suggestion {
  min-height: 40px; padding: 8px 15px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 999px; cursor: pointer; color: var(--text);
}
.suggestion:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn, .suggestion, .project { transition: background-color 0.1s, border-color 0.1s; }

.msg-user { display: flex; justify-content: flex-end; }
.msg-user .msg-body { max-width: 85%; padding: 10px 15px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; }
.msg-user-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-assistant .msg-body { display: flex; flex-direction: column; gap: 12px; }

.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 3px 11px 3px 9px; font-size: 13px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.chip[data-state='ok'] .icon { color: var(--green); }
.chip[data-state='error'] { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.chip-count { color: var(--text); font-weight: 600; }
.chip-project { color: var(--text); padding-left: 8px; border-left: 1px solid var(--line-strong); overflow-wrap: anywhere; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }

.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

.notice, .turn-error { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; padding: 9px 12px; border-radius: 8px; }
.notice { color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); }
.turn-error { color: var(--red-text); background: color-mix(in srgb, var(--red) 9%, transparent); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.notice .icon, .turn-error .icon { margin-top: 4px; }
.boot-error { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }

/* Güvenli Markdown ------------------------------------------------------- */
.md { overflow-wrap: anywhere; }
.md > * + * { margin-top: 0.7em; }
.md .md-heading { font-weight: 650; }
.md-list { padding-left: 1.4em; display: flex; flex-direction: column; gap: 3px; }
ul.md-list { list-style: disc; }
.md-inline-code { padding: 1px 6px; font: 0.9em var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; }
.md-code { margin-bottom: 0; padding: 12px 14px; overflow-x: auto; font: 13px/1.5 var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; }
.md-code code { white-space: pre; }

/* Onay kartı ----------------------------------------------------------- */
.action-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--accent-line); border-left-width: 4px; border-radius: var(--radius);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.action-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.action-head .icon { font-size: 20px; color: var(--accent); }
.action-title { font-size: 16.5px; font-weight: 650; }
.action-state { margin-left: auto; padding: 1px 10px; font-size: 12px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border-radius: 999px; }
.action-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.action-facts dt { color: var(--muted); }
.action-facts dd { overflow-wrap: anywhere; }
.action-reason-label { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: -6px; }
.action-reason { white-space: pre-wrap; overflow-wrap: anywhere; }
.action-value { display: flex; flex-direction: column; gap: 6px; }
.action-value-label { font-size: 14px; font-weight: 600; }
.action-secret-tag { margin-left: 6px; font-size: 11.5px; font-weight: 600; color: var(--amber); }
.action-value-row { display: flex; gap: 8px; }
.action-input { flex: 1; min-width: 0; min-height: 42px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 12px; }
.action-input[aria-invalid='true'] { border-color: var(--red); }
.action-toggle { min-width: 44px; }
.action-note { font-size: 13px; color: var(--muted); }
.action-nochange { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--muted); }
.action-nochange .icon { margin-top: 4px; }
.action-error { color: var(--red); font-size: 13.5px; font-weight: 600; }
.action-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; }
.action-countdown { font: 13px var(--mono); color: var(--muted); }
.action-buttons { display: flex; gap: 10px; margin-left: auto; }
.action-card.is-resolved { padding: 10px 14px; box-shadow: none; border-color: var(--line); border-left-width: 4px; }
.action-card.is-done { border-left-color: var(--green); }
.action-card.is-closed { border-left-color: var(--line-strong); }
.action-summary { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.action-summary .icon { margin-top: 4px; }
.action-summary.is-ok .icon { color: var(--green); }
.action-summary.is-ok { color: var(--text); }

/* Bekleyen şerit ve yazma alanı ---------------------------------------- */
.pending { padding: 10px 24px 0; border-top: 1px solid var(--line); background: var(--panel); max-height: 45vh; overflow-y: auto; }
.pending > * { max-width: var(--col); margin-inline: auto; }
.pending-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.pending-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }

.composer { padding: 10px 24px 14px; background: var(--bg); }
.composer > * { max-width: var(--col); margin-inline: auto; }
.focus-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.focus-name { color: var(--text); padding: 1px 8px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; }
.focus-clear { min-height: 32px; padding: 0 6px; background: none; border: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.input { flex: 1; resize: none; max-height: 200px; min-height: 46px; line-height: 1.45; padding: 11px 14px; border-radius: 12px; }
.input::placeholder { color: var(--faint); }
.composer-btn { min-height: 46px; }
.composer-hint { margin-top: 6px; font-size: 12px; color: var(--faint); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* Küçük ekran ---------------------------------------------------------- */
@media (max-width: 799px) {
  .app { display: flex; flex-direction: column; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); flex: none; max-height: 75dvh; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; }
  .btn.drawer-toggle { display: inline-flex; min-height: 44px; padding: 0 12px; font-size: 14px; white-space: nowrap; flex: none; }
  .main { flex: 1; }
  .sidebar[data-open='false'] .sidebar-body { display: none; }
  .sidebar-body { padding: 4px 14px 16px; }
  .messages { padding: 18px 14px 8px; }
  .pending { padding-inline: 14px; }
  .composer { padding: 8px 14px 12px; }
  .composer-hint { display: none; }
  .btn, .select, .suggestion, .project, .lang-btn, .focus-clear { min-height: 44px; }
  .empty { margin-top: 3vh; }
  .msg-user .msg-body { max-width: 92%; }
  .action-card { padding: 14px; }
  .action-buttons { width: 100%; }
  .action-buttons .btn { flex: 1; }
  .composer-btn span { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .composer-btn { min-width: 48px; padding: 0 12px; }
  .composer-btn.btn-primary .icon, .composer-btn.btn-secondary .icon { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* Geri bildirim ve konuşma kaydı notu */
.transcript-note { margin-top: 4px; font-size: 12px; color: var(--faint); }
.feedback { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.feedback-buttons { display: flex; gap: 4px; }
.feedback-btn { padding: 2px 10px; }
.feedback-btn[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); }
.feedback-field { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 420px; }
.feedback-status { font-size: 12px; color: var(--muted); align-self: center; }
