:root {
  --bg: #0d1117;
  --bg-2: #11161d;
  --bg-3: #161b22;
  --panel: #1a2030;
  --panel-2: #232b3d;
  --border: #2a3142;
  --text: #e6edf3;
  --muted: #8b95a7;
  --accent: #4ea8de;
  --accent-2: #2f6fb5;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: 56px 1fr 28px;
  grid-template-columns: 340px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar content"
    "status status";
  height: 100vh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: linear-gradient(180deg, #131a26, #0f141d);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6cb4ff);
  border-radius: 8px;
  font-weight: 700;
  color: #0b1320;
}
.brand .title { font-weight: 700; letter-spacing: 0.3px; }
.brand .subtitle { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 6px; margin-left: 16px; }
.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); border-color: #3a4356; }
.tab.active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--accent-2);
}

.conn-status {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12px;
}
.conn-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5);
}
.conn-status.connected .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(63, 185, 80, 0.15); }
.conn-status.connecting .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.conn-status.error .dot { background: var(--err); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(210, 153, 34, 0); }
  100% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0); }
}

.sidebar {
  grid-area: sidebar;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.panel { padding: 16px; }
.panel h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
label input,
label select,
label textarea,
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(78, 168, 222, 0.18);
}

.auth-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.auth-tab {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.auth-tab.active { background: var(--panel-2); color: var(--text); border-color: var(--accent-2); }
.auth-pane.hidden { display: none; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.file-row input[type="file"] { width: auto; }

.advanced { margin-top: 6px; }
.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover:not(:disabled) { background: #2b3548; border-color: #3a4356; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: #3b80c8; }
.btn.danger { background: #4a1f24; border-color: #6b2b30; color: #ffb4b8; }
.btn.danger:hover:not(:disabled) { background: #5a262c; }
.btn.ghost { background: transparent; }
.btn.icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.btn.icon.spinning { animation: spin 0.9s linear infinite; pointer-events: none; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.model-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.model-row select { flex: 1; min-width: 0; }

.content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

.terminal-toolbar,
.sftp-toolbar,
.sessions-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.terminal-toolbar input, .sftp-toolbar input, .sessions-toolbar input {
  width: auto; min-width: 220px;
  padding: 6px 10px; font-size: 12px;
}
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 12px; }

.terminal-host {
  flex: 1;
  min-height: 0;
  padding: 10px;
  background: #000;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.xterm-viewport, .xterm-screen { background: #000 !important; }
.xterm .xterm-viewport { background: transparent !important; }

/* xterm'in kendi scrollback scrollbar'i (görünür) */
.xterm .xterm-viewport::-webkit-scrollbar { width: 10px; background: rgba(0, 0, 0, 0.2); }
.xterm .xterm-viewport::-webkit-scrollbar-track { background: transparent; }
.xterm .xterm-viewport::-webkit-scrollbar-thumb { background: #3a4360; border-radius: 5px; }
.xterm .xterm-viewport::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.xterm .xterm-viewport { scrollbar-color: #3a4360 transparent; scrollbar-width: thin; }

/* Çoklu terminal sekme barı */
.term-tabbar {
  display: flex;
  gap: 4px;
  padding: 6px 10px 0 10px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.term-tabbar::-webkit-scrollbar { height: 4px; }
.term-tabbar::-webkit-scrollbar-thumb { background: var(--border); }

.term-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  border-radius: 8px 8px 0 0;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  position: relative;
  top: 1px;
}
.term-tab:hover { color: var(--text); border-color: #3a4356; }
.term-tab.active {
  background: #000;
  color: var(--text);
  border-color: var(--accent-2);
}
.term-tab .tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.term-tab.connected .tab-dot { background: var(--ok); }
.term-tab.connecting .tab-dot { background: var(--warn); animation: pulse 1.2s infinite; }
.term-tab.error .tab-dot { background: var(--err); }
.term-tab .tab-label {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.term-tab .close-x {
  font-size: 13px;
  opacity: 0.6;
  padding: 0 2px;
  border-radius: 3px;
  line-height: 1;
}
.term-tab .close-x:hover { opacity: 1; color: var(--err); background: rgba(248, 81, 73, 0.15); }

.term-tabbar .new-tab {
  padding: 6px 12px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
}
.term-tabbar .new-tab:hover { color: var(--text); border-color: var(--accent); }

/* Çoklu terminal pane'leri */
.term-pane-host {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #000;
}
.term-pane {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 8px;
  background: #000;
}
.term-pane.active { display: flex; }
.term-pane .terminal-host-inner {
  flex: 1;
  min-height: 0;
}

/* Mini scroll göstergesi (sağda) */
.term-scroll-indicator {
  position: absolute;
  right: 14px;
  bottom: 14px;
  background: rgba(20, 25, 35, 0.92);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 5;
  line-height: 1.4;
  user-select: none;
}
.term-scroll-indicator .scroll-line { color: var(--text); }
.term-scroll-indicator .scroll-pct { color: var(--accent); }

.sftp-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.sftp-list {
  border-right: 1px solid var(--border);
  overflow: auto;
  background: var(--bg-2);
}
.sftp-row {
  display: grid;
  grid-template-columns: 32px 1fr 110px 160px 80px;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
  cursor: pointer;
}
.sftp-row:hover { background: var(--panel); }
.sftp-row.selected { background: var(--panel-2); }
.sftp-header {
  position: sticky; top: 0;
  background: var(--bg-3);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: default;
}
.sftp-row .icon { font-size: 16px; text-align: center; }
.sftp-row.dir .icon { color: var(--accent); }
.sftp-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sftp-preview {
  overflow: auto;
  padding: 12px;
  background: var(--bg-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sessions-list {
  flex: 1;
  overflow: auto;
  padding: 14px;
}
.session-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.session-card .meta { flex: 1; }
.session-card .meta .name { font-weight: 600; }
.session-card .meta .sub { color: var(--muted); font-size: 12px; }
.session-card .actions { display: flex; gap: 6px; }

.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

dialog {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px;
  max-width: 460px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h4 { margin: 0 0 10px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3245; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a4360; }

/* ---------- WireGuard ---------- */
.wg-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.wg-toolbar input[type="text"], .wg-toolbar input[type="number"] {
  width: auto;
  min-width: 140px;
  padding: 6px 10px;
  font-size: 12px;
}
.wg-toolbar .check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.wg-toolbar .check input { width: auto; margin: 0; }

.wg-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: var(--bg);
}
.wg-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
}
.wg-panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.wg-output {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
  color: var(--text);
}
.wg-output.muted { color: var(--muted); }

.wg-install-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.wg-install-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}
.wg-install-grid input {
  margin: 0;
}

.wg-add-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.4fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}
.wg-add-form label { margin: 0; }
.wg-add-form input { margin: 0; }

.wg-peer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.wg-peer-table th, .wg-peer-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.wg-peer-table th {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-3);
}
.wg-peer-table td.pubkey {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  word-break: break-all;
  max-width: 320px;
}

.wg-client-result {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  align-items: start;
}
.wg-qr {
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.wg-qr canvas, .wg-qr img {
  display: block;
  max-width: 100%;
  height: auto;
}
.wg-qr.empty::before {
  content: 'QR burada görünecek';
  color: #999;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .wg-body { grid-template-columns: 1fr; }
  .wg-add-form { grid-template-columns: 1fr 1fr; }
  .wg-client-result { grid-template-columns: 1fr; }
}

/* WGDashboard paneli */
.wg-dashboard-panel {
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--bg-2), rgba(78, 168, 222, 0.06));
}
.wg-dashboard-panel h3::before {
  content: '⚡ ';
  color: var(--accent);
}
.wg-dashboard-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
  flex-wrap: wrap;
}
.muted.small { font-size: 11px; margin-left: 6px; }
.wg-dashboard-panel .advanced { margin-top: 6px; }
.wg-dashboard-panel .advanced summary {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
}

/* === A'dan Z'ye Sihirbaz === */
.wg-wizard-panel {
  border: 2px solid #2ea043;
  background: linear-gradient(180deg, #102218 0%, #0d1117 100%);
}
.wg-wizard-panel h3 { color: #2ea043; }
.wg-wizard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  margin: 10px 0;
}
.wg-wizard-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
}
.wg-wizard-grid input {
  margin-top: 4px;
}
.wg-wizard-check {
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
}
.wg-wizard-steps {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  counter-reset: wizstep;
}
.wg-wizard-steps li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--bg-3);
  border-radius: 6px;
  margin-bottom: 6px;
  background: var(--bg-2);
  font-size: 13px;
}
.wg-wizard-steps li.wiz-running {
  border-color: #d29922;
  background: #2a2419;
}
.wg-wizard-steps li.wiz-ok {
  border-color: #2ea043;
  background: #1c2a22;
}
.wg-wizard-steps li.wiz-fail {
  border-color: #f85149;
  background: #2a1a1a;
}
.wg-wizard-steps li.wiz-skip {
  opacity: 0.6;
}
.wg-step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.wiz-running .wg-step-dot { background: #d29922; color: #fff; }
.wiz-ok .wg-step-dot { background: #2ea043; color: #fff; }
.wiz-fail .wg-step-dot { background: #f85149; color: #fff; }
.wg-step-status {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
.wg-wizard-log {
  margin-top: 10px;
}
.wg-wizard-log summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0;
}
.wg-wizard-result {
  margin-top: 14px;
  padding: 14px;
  border: 2px solid #2ea043;
  border-radius: 8px;
  background: #102218;
}
.wg-wizard-result h4 { color: #2ea043; margin-top: 0; }
.wg-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.wg-result-grid h5 { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.wg-result-grid textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 4px;
  padding: 6px;
}
.wg-wizard-result ul { padding-left: 20px; margin: 6px 0; }
.wg-wizard-result li { margin: 4px 0; }
.wg-wizard-result a { color: #58a6ff; text-decoration: none; }
.wg-wizard-result a:hover { text-decoration: underline; }

/* === AI Asistan Chat Balonu === */
.ai-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
}
.ai-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6e40c9, #4f46e5);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.ai-chat-toggle:hover { transform: scale(1.05); box-shadow: 0 6px 24px rgba(110, 64, 201, 0.5); }
.ai-chat-icon { pointer-events: none; }
.ai-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f85149;
  color: #fff;
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--bg);
}
.ai-chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 420px;
  height: 560px;
  max-height: 80vh;
  background: var(--panel, #1a2030);
  border: 1px solid var(--bg-3, #2a3142);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease, height 0.18s ease;
}
.ai-chat-panel.ai-size-s {
  width: 320px;
  height: 420px;
}
.ai-chat-panel.ai-size-m {
  width: 420px;
  height: 560px;
}
.ai-chat-panel.ai-size-l {
  width: 600px;
  height: 720px;
}
.ai-size-btn {
  font-size: 14px;
  font-weight: bold;
}
  overflow: hidden;
}
.ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(90deg, #2a1f4d, #1a2030);
  border-bottom: 1px solid var(--bg-3);
}
.ai-chat-header strong { color: #c4a8ff; font-size: 14px; }
.ai-chat-header small { display: block; font-size: 10px; margin-top: 2px; }
.ai-chat-actions { display: flex; gap: 6px; }
.ai-icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.ai-icon-btn:hover { background: var(--bg-3); color: var(--fg); border-color: var(--bg-3); }
.ai-chat-context {
  padding: 8px 14px;
  background: var(--bg-2, #11161d);
  border-bottom: 1px solid var(--bg-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}
.ai-ctx-toggle { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.ai-ctx-toggle input { margin: 0; }
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.ai-msg {
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 95%;
  word-wrap: break-word;
}
.ai-msg-system {
  background: rgba(110, 64, 201, 0.1);
  border: 1px solid rgba(110, 64, 201, 0.3);
  color: var(--muted);
  font-size: 12px;
  align-self: center;
  text-align: center;
}
.ai-msg-user {
  background: #1f6feb;
  color: #fff;
  align-self: flex-end;
}
.ai-msg-assistant {
  background: var(--bg-3);
  color: var(--fg);
  align-self: flex-start;
}
.ai-msg-assistant pre {
  background: var(--bg);
  border: 1px solid var(--bg-3);
  padding: 6px 8px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 11px;
}
.ai-msg-assistant code {
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.ai-msg-error {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ffb4ad;
  align-self: center;
  font-size: 12px;
}
.ai-msg-tool {
  background: rgba(46, 160, 67, 0.1);
  border: 1px solid rgba(46, 160, 67, 0.3);
  font-size: 11px;
  padding: 6px 10px;
  color: var(--muted);
}
.ai-msg-tool strong { color: #2ea043; }
.ai-tool-card {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-tool-card .ai-tool-title { font-weight: 700; color: #d29922; }
.ai-tool-card .ai-tool-cmd {
  font-family: var(--mono);
  background: var(--bg);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  word-break: break-all;
}
.ai-tool-card .ai-tool-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.ai-tool-card button {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--bg-3);
  background: var(--bg-3);
  color: var(--fg);
  cursor: pointer;
}
.ai-tool-card button.ai-tool-approve {
  background: #238636;
  border-color: #2ea043;
  color: #fff;
}
.ai-tool-card button.ai-tool-approve:hover { background: #2ea043; }
.ai-tool-card button.ai-tool-reject:hover { background: #6e2c2c; }
.ai-chat-input-wrap {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--bg-3);
  background: var(--bg-2);
}
.ai-chat-input-wrap textarea {
  flex: 1;
  resize: none;
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.ai-chat-send {
  align-self: stretch;
  padding: 6px 12px;
}
.ai-chat-typing {
  display: inline-block;
  padding: 8px 12px;
  background: var(--bg-3);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* AI Ayarlar modalı */
.ai-modal {
  position: fixed;
  inset: 0;
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-modal[hidden] { display: none; }
.ai-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.ai-modal-content {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--bg-3);
  border-radius: 10px;
  padding: 20px;
  width: 90%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.ai-modal-content h3 { margin: 0 0 8px; color: #c4a8ff; }
.ai-modal-content label { display: block; margin: 12px 0 4px; font-size: 12px; color: var(--muted); }
.ai-modal-content input,
.ai-modal-content select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 6px;
  font-size: 13px;
}
.ai-modal-content small { display: block; margin: 4px 0 8px; font-size: 11px; }
.ai-modal-content .form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* WG Sihirbaz Modal — büyük, scroll'lu */
.ai-modal-wide {
  width: 720px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.ai-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.ai-modal-close:hover { color: var(--fg); }

.wiz-config { background: var(--bg-3); border-radius: 8px; padding: 12px; margin: 8px 0 12px; }
.wiz-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.wiz-config-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.wiz-config-grid input {
  padding: 6px 8px;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 4px;
  font-size: 13px;
}
.wiz-config-checks { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.wiz-config-checks .check { font-size: 12px; }

.wiz-steps {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wiz-steps li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  padding: 10px;
  background: var(--bg-3);
  border-radius: 8px;
  align-items: start;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.wiz-steps li.wiz-running { border-color: var(--accent); background: rgba(196, 168, 255, 0.08); }
.wiz-steps li.wiz-ok { border-color: #3ec46d; background: rgba(62, 196, 109, 0.08); }
.wiz-steps li.wiz-fail { border-color: #ff6464; background: rgba(255, 100, 100, 0.08); }
.wiz-steps li.wiz-skip { opacity: 0.5; }
.wiz-steps li .wiz-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-2);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}
.wiz-steps li.wiz-running .wiz-num { background: var(--accent); color: var(--bg); }
.wiz-steps li.wiz-ok .wiz-num { background: #3ec46d; color: #fff; }
.wiz-steps li.wiz-fail .wiz-num { background: #ff6464; color: #fff; }
.wiz-steps li > div b { display: block; font-size: 13px; }
.wiz-steps li > div p { margin: 2px 0 4px; }
.wiz-steps li .wiz-status {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-2);
}
.wiz-steps li.wiz-running .wiz-status { background: var(--accent); color: var(--bg); }
.wiz-steps li.wiz-ok .wiz-status { background: #3ec46d; color: #fff; }
.wiz-steps li.wiz-fail .wiz-status { background: #ff6464; color: #fff; }
.wiz-steps li .wiz-run {
  align-self: center;
  white-space: nowrap;
}
.wiz-steps li .wiz-step-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: center;
}
.wiz-steps li .wiz-existing {
  font-size: 11px;
  padding: 4px 8px;
  white-space: nowrap;
}
.wiz-steps li .wiz-skip {
  font-size: 11px;
  padding: 4px 8px;
  white-space: nowrap;
  opacity: 0.85;
}
.wiz-steps li .wiz-skip:hover { opacity: 1; }

/* Atlanan adımları görsel olarak ayır */
.wiz-steps li.wiz-skip {
  opacity: 0.55;
}
.wiz-steps li.wiz-skip .wiz-status {
  color: #aaa;
}
.wiz-steps li .wiz-out {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  padding: 8px;
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: 4px;
  font-size: 11px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  display: none;
}
.wiz-steps li.wiz-ok .wiz-out,
.wiz-steps li.wiz-fail .wiz-out { display: block; }

.wiz-result {
  margin-top: 12px;
  padding: 12px;
  background: rgba(62, 196, 109, 0.08);
  border: 1px solid #3ec46d;
  border-radius: 8px;
}
.wiz-result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 8px;
}
.wiz-result-grid h5 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.wiz-result-grid textarea {
  width: 100%;
  background: var(--bg-1);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 4px;
  padding: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}
.wiz-result ul { margin: 0; padding-left: 20px; }

@media (max-width: 480px) {
  .ai-chat-panel,
  .ai-chat-panel.ai-size-s,
  .ai-chat-panel.ai-size-m,
  .ai-chat-panel.ai-size-l { width: calc(100vw - 30px); right: 15px; height: 70vh; }
  .wiz-config-grid { grid-template-columns: 1fr; }
  .wiz-steps li { grid-template-columns: 28px 1fr; }
  .wiz-steps li .wiz-run { grid-column: 2; }
}