/* ==========================================================================
   LOCAL AI STUDIO v2
   PART 1 of 3 — variables, reset, background, sidebar
   ========================================================================== */

:root{
  --text:      #1c1f26;
  --text-2:    #4a5262;
  --muted:     #8a92a3;
  --muted-2:   #aab2c2;

  --glass:        rgba(255, 255, 255, 0.72);
  --glass-soft:   rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-inner:  rgba(255, 255, 255, 0.7);

  --border:        rgba(20, 26, 40, 0.08);
  --border-strong: rgba(20, 26, 40, 0.14);

  --accent:       #1c1f26;
  --accent-hover: #2d323d;
  --accent-text:  #ffffff;

  --code-bg:     #f8f9fc;
  --code-head:   #f1f3f8;
  --user-bubble: rgba(20, 26, 40, 0.06);
  --danger:      #e5484d;
  --ok:          #2f9e56;

  --radius:    18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(20,26,40,0.04), 0 2px 8px rgba(20,26,40,0.05);
  --shadow-md: 0 2px 6px rgba(20,26,40,0.04), 0 12px 34px rgba(20,26,40,0.10);
  --shadow-lg: 0 8px 40px rgba(20,26,40,0.14);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
          Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*{ box-sizing: border-box; }
html,body{ height:100%; margin:0; }

body::before{
  content:"";
  position: fixed; inset:0; z-index:-1;
  background:
    radial-gradient(circle at 12% 8%,  rgba(180, 200, 255, 0.32), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(255, 205, 220, 0.24), transparent 42%),
    radial-gradient(circle at 60% 40%, rgba(210, 225, 255, 0.20), transparent 50%),
    linear-gradient(135deg, #eef1f7 0%, #f7f9fc 50%, #eef2f8 100%);
  pointer-events: none;
}

body{
  font-family: var(--font);
  color: var(--text);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  gap: 12px;
  padding: 12px;
  height: 100vh;
  overflow: hidden;
}

::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-thumb{
  background: rgba(20,26,40,0.14);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover{
  background: rgba(20,26,40,0.24);
  background-clip: padding-box;
}
::-webkit-scrollbar-track{ background: transparent; }

/* ============================== SIDEBAR ================================= */
.sidebar{
  width: 264px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: margin-left .25s ease, opacity .2s ease;
  contain: layout style paint;
}
.sidebar.hidden{
  margin-left: calc(-264px - 12px);
  opacity: 0;
  pointer-events: none;
}

.side-head{ padding: 16px 14px 10px; }

.brand{
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .1px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px;
  color: var(--text);
}
.brand span{
  background: linear-gradient(135deg, #5b6bff, #a05bff);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.btn-new{
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--glass-inner);
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  display: flex; align-items: center; gap: 9px;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
  font-family: inherit;
}
.btn-new:hover{
  background: rgba(255,255,255,0.95);
  border-color: var(--border-strong);
}
.btn-new:active{ transform: scale(0.985); }
.plus{
  font-size: 16px; font-weight: 400;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}

.conv-list{
  flex: 1; overflow-y: auto;
  padding: 8px 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}

.conv-item{
  padding: 9px 11px;
  border-radius: 11px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  position: relative;
  transition: background .15s ease;
  border: 1px solid transparent;
}
.conv-item:hover{ background: rgba(255,255,255,0.6); }
.conv-item.active{
  background: rgba(255,255,255,0.92);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.ci-main{ flex: 1; min-width: 0; }
.ci-title{
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-date{ font-size: 11px; color: var(--muted); margin-top: 2px; }

.ci-del{
  opacity: 0;
  border: none; background: transparent;
  color: var(--muted); cursor: pointer;
  font-size: 12px;
  padding: 4px 6px; border-radius: 6px;
  transition: .15s ease;
  font-family: inherit;
}
.conv-item:hover .ci-del{ opacity: 1; }
.ci-del:hover{ color: var(--danger); background: rgba(229,72,77,0.1); }

.side-foot{
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.side-foot button{
  background: transparent; border: none;
  color: var(--text-2); text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 9px;
  font-size: 13px; font-family: inherit;
  display: flex; align-items: center; gap: 9px;
  transition: background .15s ease;
}
.side-foot button:hover{ background: rgba(255,255,255,0.7); color: var(--text); }

.folder-line{
  font-size: 11.5px;
  color: var(--muted);
  padding: 6px 10px 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Backdrop base (mobile only — hidden on desktop) */
.sidebar-backdrop{ display: none; }
















































/* ============================== WORKSPACE =============================== */
.workspace{
  flex: 1;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.chat-pane, .code-pane{
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  overflow: hidden;
  contain: layout style paint;
}

.chat-pane{ flex: 1; min-width: 0; }

.code-pane{
  width: 460px;
  flex-shrink: 0;
  transition: width .25s ease, margin-right .25s ease, opacity .2s ease;
}
.code-pane.hidden{
  width: 0;
  margin-right: -12px;
  opacity: 0;
  pointer-events: none;
  border-width: 0;
}

/* ============================== TOPBAR ================================== */
.topbar{
  height: 58px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.icon-btn{
  background: transparent; border: none;
  color: var(--text-2);
  font-size: 15px; cursor: pointer;
  padding: 7px 10px; border-radius: 9px;
  transition: background .15s ease;
  font-family: inherit;
}
.icon-btn:hover{ background: rgba(20,26,40,0.05); color: var(--text); }

.title-input{
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 14px; font-weight: 600;
  padding: 7px 10px;
  border-radius: 10px;
  min-width: 100px; max-width: 320px;
  flex: 1;
  outline: none;
  font-family: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.title-input:hover{ border-color: var(--border); }
.title-input:focus{
  border-color: var(--border-strong);
  background: rgba(255,255,255,0.75);
}

.spacer{ flex: 1; }

.mode-toggle{
  display: flex;
  background: rgba(20,26,40,0.05);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px; gap: 2px;
}
.mode-toggle button{
  border: none; background: transparent;
  color: var(--text-2);
  padding: 6px 13px; border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px; font-weight: 600;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
  font-family: inherit;
}
.mode-toggle button.active{
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 2px 6px rgba(20,26,40,0.18);
}
.mode-toggle button:not(.active):hover{ color: var(--text); }

.model-select{
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12.5px;
  max-width: 220px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.model-select:focus{ border-color: var(--border-strong); }

/* ============================== MESSAGES ================================ */
.messages{
  flex: 1;
  overflow-y: auto;
  padding: 26px 22px 8px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.msg{
  max-width: 780px;
  margin: 0 auto 22px;
  display: flex;
  gap: 14px;
  animation: fade .18s ease;
}
@keyframes fade{
  from{ opacity:0; transform: translateY(4px); }
  to{ opacity:1; transform: none; }
}

.avatar{
  width: 30px; height: 30px; min-width: 30px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
  margin-top: 2px;
  letter-spacing: .3px;
}
.msg.user .avatar{ display: none; }
.msg.assistant .avatar{
  background: linear-gradient(135deg, #5b6bff, #a05bff);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91,107,255,0.3);
}

.msg.user{ justify-content: flex-end; }
.msg.user .content{
  background: var(--user-bubble);
  padding: 10px 15px;
  border-radius: 18px;
  max-width: 75%;
  flex: 0 1 auto;
}

.content{
  flex: 1;
  min-width: 0;
  line-height: 1.68;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  color: var(--text);
}
.msg.user .content{ white-space: pre-wrap; }

.content p{ margin: 0 0 12px; }
.content p:last-child{ margin-bottom: 0; }
.content h1,.content h2,.content h3,.content h4{
  margin: 20px 0 10px; font-weight: 700; line-height: 1.3;
}
.content h1{ font-size: 20px; }
.content h2{ font-size: 17.5px; }
.content h3{ font-size: 15.5px; }
.content ul,.content ol{ margin: 0 0 12px; padding-left: 22px; }
.content li{ margin: 5px 0; }
.content a{ color: #4356d6; }
.content blockquote{
  border-left: 3px solid var(--border-strong);
  margin: 0 0 12px;
  padding: 2px 0 2px 14px;
  color: var(--text-2);
}
.content hr{
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
.content code.inline{
  background: rgba(20,26,40,0.06);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .88em;
  font-family: var(--mono);
  color: #b8395c;
}

/* ============================== CODE BLOCK ============================== */
.codeblock{
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 14px 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.cb-head{
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--code-head);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
}
.cb-lang{
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: .3px;
  color: var(--text-2);
}
.cb-file{
  color: #4356d6;
  font-weight: 600;
  font-family: var(--mono);
}
.cb-spacer{ flex: 1; }
.cb-btn{
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 11px;
  display: flex; align-items: center; gap: 5px;
  transition: .15s ease;
  font-family: inherit;
}
.cb-btn:hover{
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
}
.cb-btn.copied{
  color: var(--ok);
  border-color: rgba(47,158,86,0.4);
  background: rgba(47,158,86,0.06);
}
.codeblock pre{
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.62;
  font-family: var(--mono);
}
.codeblock code{
  font-family: inherit;
  color: #24292f;
  white-space: pre;
}

/* ============================== CODE PANE =============================== */
.cp-head{
  height: 58px;
  display: flex; align-items: center;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}
.cp-title{
  display: flex; align-items: center; gap: 9px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.cp-dot{
  width: 9px; height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b6bff, #a05bff);
  box-shadow: 0 0 8px rgba(91,107,255,0.4);
}
.cp-actions{
  margin-left: auto;
  display: flex; gap: 6px; flex-wrap: wrap;
}

.cp-files{
  border-bottom: 1px solid var(--border);
  max-height: 170px;
  overflow-y: auto;
  padding: 6px 8px;
  flex-shrink: 0;
}
.cp-file{
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  font-family: var(--mono);
  transition: background .12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-file:hover{ background: rgba(20,26,40,0.04); }
.cp-file.active{
  background: rgba(20,26,40,0.07);
  color: var(--text);
  font-weight: 600;
}
.cp-file .ico{ flex-shrink: 0; font-size: 13px; }
.cp-file .path{ overflow: hidden; text-overflow: ellipsis; }

.cp-viewer{
  flex: 1;
  overflow: auto;
  min-height: 0;
  background: var(--code-bg);
}
.cp-viewer pre{
  margin: 0;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: #24292f;
  white-space: pre;
  min-height: 100%;
}

.cp-empty{
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%;
  padding: 40px 30px;
  text-align: center;
  color: var(--muted);
  background: var(--code-bg);
}
.cp-empty-icon{
  font-size: 40px;
  margin-bottom: 14px;
  opacity: .65;
  filter: grayscale(0.4);
}
.cp-empty-title{
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}
.cp-empty-text{
  font-size: 12.5px;
  line-height: 1.65;
  max-width: 280px;
}
.cp-empty-text b{ color: var(--text); }



































































/* ============================== COMPOSER ================================ */
.composer-wrap{
  padding: 6px 20px 18px;
  flex-shrink: 0;
}
.composer{
  max-width: 780px;
  margin: 0 auto;
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.95);
  border-radius: 16px;
  padding: 9px 9px 9px 16px;
  display: flex; align-items: flex-end; gap: 9px;
  box-shadow: var(--shadow-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within{
  border-color: var(--border-strong);
  box-shadow: 0 4px 14px rgba(20,26,40,0.08), 0 16px 40px rgba(20,26,40,0.12);
}
#input{
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text);
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  max-height: 210px;
  padding: 7px 0;
}
#input::placeholder{ color: var(--muted-2); }

.send-btn{
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 11px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .1s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(20,26,40,0.18);
}
.send-btn:hover:not(:disabled){ background: var(--accent-hover); }
.send-btn:active:not(:disabled){ transform: scale(0.95); }
.send-btn:disabled{ opacity: .35; cursor: not-allowed; box-shadow: none; }
.send-btn.stop{ background: var(--danger); box-shadow: 0 2px 8px rgba(229,72,77,0.3); }

.hint{
  max-width: 780px;
  margin: 9px auto 0;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  min-height: 15px;
}

/* ============================== MODAL =================================== */
.overlay{
  position: fixed; inset: 0;
  background: rgba(20,26,40,0.35);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay.show{ display: flex; }

.modal{
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--glass-strong);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal h2{ margin: 0 0 4px; font-size: 17px; }
.modal .sub{
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.field{ margin-bottom: 17px; }
.field label{
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--text-2);
}
.field input[type="text"],
.field input[type="password"],
.field select{
  width: 100%;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus{ border-color: var(--border-strong); }
.field input[type="range"]{ width: 100%; accent-color: var(--accent); }

.row{ display: flex; gap: 9px; }

.prov-tabs{
  display: flex; gap: 7px;
  margin-bottom: 16px;
}
.prov-tabs button{
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.55);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: .15s ease;
  font-family: inherit;
}
.prov-tabs button:hover{ background: rgba(255,255,255,0.9); }
.prov-tabs button.active{
  border-color: var(--border-strong);
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 2px 8px rgba(20,26,40,0.18);
}

.modal-foot{
  display: flex; gap: 9px;
  justify-content: flex-end;
  margin-top: 22px;
}

.note{
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
  background: rgba(20,26,40,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
}
.note b{ color: var(--text-2); }
.note code{
  background: rgba(20,26,40,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .9em;
}

.status{ font-size: 12px; margin-top: 8px; min-height: 16px; }
.status.ok{ color: var(--ok); }
.status.err{ color: var(--danger); }

.ap-btn{
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.75);
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: .15s ease;
  font-family: inherit;
  white-space: nowrap;
}
.ap-btn:hover{ background: #fff; border-color: var(--border-strong); }
.ap-btn:active{ transform: scale(0.97); }
.ap-btn.primary{
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 2px 8px rgba(20,26,40,0.18);
}
.ap-btn.primary:hover{ background: var(--accent-hover); }
.ap-btn:disabled{ opacity: .5; cursor: not-allowed; }

.ap-status{
  font-size: 12px;
  color: var(--ok);
  align-self: center;
  padding: 0 6px;
}

/* ============================== WELCOME / TYPING / ERRORS ============== */
.welcome{
  max-width: 620px;
  margin: 60px auto;
  text-align: center;
  color: var(--text-2);
}
.welcome h1{
  font-size: 26px;
  color: var(--text);
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: -.3px;
}
.welcome p{ line-height: 1.75; font-size: 13.5px; color: var(--text-2); }
.welcome .kbd{
  background: rgba(20,26,40,0.06);
  padding: 3px 9px;
  border-radius: 7px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.typing{
  display: inline-block;
  width: 7px; height: 15px;
  background: var(--accent);
  vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
  border-radius: 2px;
}
@keyframes blink{
  0%, 50%{ opacity: 1; }
  51%, 100%{ opacity: 0; }
}

.err-box{
  background: rgba(229,72,77,0.08);
  border: 1px solid rgba(229,72,77,0.28);
  color: #a8262b;
  padding: 12px 15px;
  border-radius: 11px;
  font-size: 13px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.msg-actions{
  display: flex; gap: 6px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity .15s ease;
}
.msg:hover .msg-actions{ opacity: 1; }
.msg-actions button{
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: 7px;
  font-family: inherit;
  transition: .15s ease;
}
.msg-actions button:hover{
  background: rgba(20,26,40,0.05);
  color: var(--text);
}

/* ============================== PROVIDER INFO BOX ====================== */
.prov-info{
  background: rgba(20,26,40,0.035);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
}
.prov-info h4{
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 700;
}
.prov-info p{ margin: 0 0 10px; }
.prov-info a{ color: #4356d6; font-weight: 600; }
.prov-info .kv{
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(20,26,40,0.08);
  font-size: 12px;
}
.prov-info .kv:last-of-type{ border-bottom: none; }
.prov-info .kv b{ color: var(--text); font-weight: 600; text-align: right; }
.prov-info .tip{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(20,26,40,0.08);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ============================== ABOUT / TERMS DOC ====================== */
.doc-body{
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-2);
}
.doc-body h3{
  margin: 20px 0 8px;
  font-size: 14px;
  color: var(--text);
  font-weight: 700;
}
.doc-body h3:first-child{ margin-top: 0; }
.doc-body p{ margin: 0 0 12px; }
.doc-body ol, .doc-body ul{ margin: 0 0 12px; padding-left: 22px; }
.doc-body li{ margin: 6px 0; }
.doc-body a{ color: #4356d6; font-weight: 600; }
.doc-body code{
  background: rgba(20,26,40,0.06);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: .9em;
  color: #b8395c;
}
.doc-highlight{
  background: rgba(255, 200, 80, 0.12);
  border: 1px solid rgba(200, 150, 30, 0.25);
  border-radius: 12px;
  padding: 12px 15px;
  margin: 14px 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: #6b4a10;
}

/* ============================== ONBOARDING ============================= */
.onboard-modal{ width: 600px; }
.onboard-q{
  font-size: 14px;
  margin: 22px 0 12px;
  font-weight: 700;
  color: var(--text);
}
.onboard-choices{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
.onboard-choice{
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 18px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: .18s ease;
}
.onboard-choice:hover{
  background: #fff;
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.oc-icon{ font-size: 26px; margin-bottom: 10px; }
.oc-title{
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 4px;
}
.oc-text{ font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ============================== RESPONSIVE ============================= */

/* --- Tablet --- */
@media (max-width: 1180px){
  .code-pane{ width: 380px; }
}
@media (max-width: 1024px){
  .code-pane{ width: 320px; }
}

/* --- Mobile --- */
@media (max-width: 760px){

  body{
    padding: 0;
    gap: 0;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  /* Sidebar → slide-in drawer */
  .sidebar{
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 200;
    border-radius: 0;
    border-top: none; border-bottom: none; border-left: none;
    transform: translateX(0);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    margin-left: 0;
    opacity: 1;
    contain: none;
  }
  .sidebar.hidden{
    transform: translateX(-105%);
    margin-left: 0;
    opacity: 1;
    pointer-events: none;
  }

  .sidebar-backdrop{
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20,26,40,.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  body.drawer-open .sidebar-backdrop{
    opacity: 1;
    pointer-events: auto;
  }

  /* Workspace: code strip on top, chat below */
  .workspace{
    flex: 1;
    flex-direction: column-reverse;
    gap: 0;
    min-height: 0;
  }

  .chat-pane{
    flex: 1;
    min-height: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255,255,255,.55);
    contain: none;
  }

  .code-pane{
    width: 100%;
    flex-shrink: 0;
    max-height: 54px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    background: var(--glass-strong);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: max-height .3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    contain: none;
  }
  .code-pane.hidden{
    max-height: 0;
    width: 100%;
    margin: 0;
    opacity: 1;
    pointer-events: none;
    border-bottom: none;
  }
  .code-pane.expanded{
    max-height: 60vh;
  }

  .cp-head{
    height: 54px;
    padding: 0 12px;
    cursor: pointer;
    user-select: none;
    gap: 8px;
  }
  .cp-head::after{
    content: '▾';
    margin-left: 8px;
    color: var(--muted);
    font-size: 12px;
    flex-shrink: 0;
    transition: transform .25s ease;
  }
  .code-pane.expanded .cp-head::after{
    transform: rotate(180deg);
  }
  .cp-title{ font-size: 12.5px; }
  .cp-actions{ gap: 5px; }
  .cp-actions .ap-btn{
    padding: 6px 10px;
    font-size: 11.5px;
  }
  .cp-actions .ap-status{ display: none; }

  .code-pane:not(.expanded) .cp-files,
  .code-pane:not(.expanded) .cp-viewer{
    display: none;
  }
  .code-pane.expanded .cp-files{ max-height: 120px; }

  /* Topbar */
  .topbar{
    height: 54px;
    padding: 0 6px;
    gap: 4px;
  }
  .topbar .icon-btn{
    padding: 6px 8px;
    font-size: 16px;
  }
  .title-input{
    font-size: 13px;
    padding: 6px 6px;
    max-width: 110px;
    min-width: 0;
    flex: 1;
  }
  .mode-toggle{
    padding: 2px;
    border-radius: 9px;
    flex-shrink: 0;
  }
  .mode-toggle button{
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 7px;
  }
  .model-select{
    max-width: 90px;
    font-size: 11px;
    padding: 5px 6px;
    border-radius: 8px;
    flex-shrink: 1;
    min-width: 0;
  }
  #btnToggleCode{ display: none; }

  /* Messages */
  .messages{ padding: 16px 12px 6px; }
  .msg{ gap: 10px; margin-bottom: 18px; }
  .msg.user .content{
    max-width: 85%;
    padding: 9px 13px;
    font-size: 14px;
  }
  .avatar{
    width: 26px; height: 26px; min-width: 26px;
    font-size: 9.5px;
    border-radius: 8px;
  }
  .content{ font-size: 14px; line-height: 1.65; }
  .welcome{ margin: 30px 16px; }
  .welcome h1{ font-size: 22px; }

  /* Code blocks in chat */
  .codeblock{ border-radius: 10px; margin: 12px 0; }
  .cb-head{ padding: 6px 10px; font-size: 11px; }
  .cb-btn{ padding: 3px 8px; font-size: 10.5px; border-radius: 6px; }
  .codeblock pre{
    padding: 12px 12px;
    font-size: 12px;
    line-height: 1.6;
  }

  /* Composer */
  .composer-wrap{ padding: 6px 10px 12px; }
  .composer{
    padding: 7px 7px 7px 12px;
    border-radius: 14px;
  }
  #input{ font-size: 14px; max-height: 140px; }
  .send-btn{
    width: 34px; height: 34px; min-width: 34px;
    border-radius: 10px;
  }
  .hint{ font-size: 11px; padding: 0 8px; }

  /* Modals */
  .modal{
    width: 92vw;
    max-width: 92vw;
    padding: 20px 18px;
    border-radius: 18px;
    max-height: 88vh;
  }
  .onboard-modal{ width: 92vw; max-width: 92vw; }
  .onboard-choices{
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .onboard-choice{ padding: 16px 14px; }
  .oc-icon{ font-size: 22px; margin-bottom: 8px; }
  .oc-title{ font-size: 13px; }
  .oc-text{ font-size: 11.5px; }
  .onboard-q{ font-size: 13.5px; }

  .modal-foot{ flex-wrap: wrap; gap: 8px; }
  .modal-foot .ap-btn{ flex: 1; justify-content: center; }

  .prov-info{ padding: 12px 14px; font-size: 12px; }
  .prov-info .kv{ font-size: 11.5px; flex-wrap: wrap; }

  .doc-body{ font-size: 12.5px; line-height: 1.7; }
  .doc-body h3{ font-size: 13.5px; }
}

/* --- Tiny phones --- */
@media (max-width: 420px){
  .model-select{ display: none; }
  .title-input{ max-width: 90px; font-size: 12.5px; }
  .mode-toggle button{ padding: 5px 7px; font-size: 10.5px; }
  .messages{ padding: 12px 10px 4px; }
  .msg.user .content{ max-width: 90%; }
}

/* --- Reduced transparency fallback --- */
@media (prefers-reduced-transparency: reduce){
  .sidebar, .chat-pane, .code-pane, .modal, .composer{
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255,255,255,0.96);
  }
  body::before{ background: #eef1f7; }
}











