/* Anone — phong cách neo-brutalist (tham khảo buicode.com) */

:root {
  --bg: #f4f0e6;
  --surface: #fffdf7;
  --ink: #141414;
  --line: #141414;
  --line-soft: #cfc8b6;
  --muted: #5c5a55;
  --accent: #d7ff3a;
  --accent-2: #141414;
  --accent-grad: var(--accent);
  --text: #141414;
  --bubble-user: var(--ink);
  --bubble-user-text: #fffdf7;
  --bubble-ai: #fffdf7;
  --shadow: 4px 4px 0 #141414;
  --shadow-sm: 2px 2px 0 #141414;
  --shadow-lg: 6px 6px 0 #141414;
  --radius: 4px;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.file-warning {
  background: var(--accent);
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
}
.file-warning code { background: var(--ink); color: var(--accent); padding: 1px 6px; border-radius: 3px; font-family: var(--font-mono); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--surface); border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--ink); color: var(--accent); font-weight: 800; font-size: 20px;
  border: 2px solid var(--ink); box-shadow: var(--shadow-sm); border-radius: var(--radius);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand-tag { font-size: 11px; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); border: 2px solid var(--ink); transition: background .3s; }
.status.ok .dot { background: var(--ok); }
.status.warn .dot { background: var(--warn); }
.status.err .dot { background: var(--err); }

.icon-btn {
  border: 2px solid var(--ink); background: var(--surface); cursor: pointer;
  width: 38px; height: 38px; border-radius: var(--radius); font-size: 16px;
  display: grid; place-items: center; transition: all .12s; box-shadow: var(--shadow-sm);
}
.icon-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); background: var(--accent); }
.icon-btn:active { transform: translate(1px, 1px); box-shadow: none; }

.lang-toggle { display: flex; background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius); padding: 2px; box-shadow: var(--shadow-sm); }
.lang-toggle button {
  border: 0; background: transparent; cursor: pointer; padding: 5px 12px;
  border-radius: 2px; font-weight: 700; font-size: 13px; color: var(--muted); transition: all .12s; font-family: var(--font-mono);
}
.lang-toggle button.active { background: var(--ink); color: var(--accent); }

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid; grid-template-columns: 360px 1fr; gap: 20px; padding: 20px;
  height: calc(100vh - 64px); max-width: 1280px; margin: 0 auto;
}

/* ---------------------------------------------------------------- services */
.services-panel {
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); overflow-y: auto;
}
.services-panel h2 {
  margin: 0 0 16px; font-size: 14px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink);
}
.services-list { display: flex; flex-direction: column; gap: 14px; }

.service-card {
  border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s;
}
.service-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.service-card:active { transform: translate(1px, 1px); box-shadow: none; }
.service-head { display: flex; align-items: center; gap: 10px; }
.service-icon { font-size: 24px; }
.service-name { font-weight: 800; font-size: 15px; }
.service-desc { font-size: 13px; color: var(--muted); margin: 8px 0 10px; line-height: 1.45; }
.service-features { display: flex; flex-wrap: wrap; gap: 6px; }
.feature-chip {
  font-size: 11px; font-weight: 600; color: var(--ink);
  background: var(--accent); border: 1px solid var(--ink);
  padding: 2px 8px; border-radius: var(--radius); font-family: var(--font-mono);
}
.service-cta {
  margin-top: 10px; font-size: 12px; font-weight: 800; color: var(--ink);
  display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- chat */
.chat-panel {
  display: flex; flex-direction: column; background: var(--surface);
  border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; min-height: 0;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 2px solid var(--ink); background: var(--surface);
}
.model-badge {
  background: var(--ink); color: var(--accent); font-weight: 700; font-size: 12px;
  padding: 5px 12px; border-radius: var(--radius); font-family: var(--font-mono);
}
.chat-header-right { display: flex; align-items: center; gap: 12px; }
.chat-hint { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.order-btn {
  border: 2px solid var(--ink); cursor: pointer; background: var(--accent); color: var(--ink);
  padding: 6px 14px; border-radius: var(--radius); font-weight: 800; font-size: 13px;
  box-shadow: var(--shadow-sm); transition: all .12s;
}
.order-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.order-btn:active { transform: translate(1px, 1px); box-shadow: none; }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; animation: fadeIn .2s ease; }
.msg.user { justify-content: flex-end; }
.msg.ai { justify-content: flex-start; }
.bubble {
  max-width: 78%; padding: 12px 16px; border-radius: var(--radius); line-height: 1.55;
  font-size: 14.5px; word-break: break-word;
}
.msg.user .bubble {
  background: var(--bubble-user); color: var(--bubble-user-text);
  border: 2px solid var(--ink); box-shadow: var(--shadow-sm);
}
.msg.ai .bubble {
  background: var(--bubble-ai); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: var(--shadow-sm);
}
.msg.ai .bubble p { margin: 0 0 8px; }
.msg.ai .bubble p:last-child { margin-bottom: 0; }
.msg.ai .bubble ul, .msg.ai .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.ai .bubble li { margin: 3px 0; }
.msg.ai .bubble h1, .msg.ai .bubble h2, .msg.ai .bubble h3 { margin: 10px 0 6px; font-size: 15px; }
.msg.ai .bubble code {
  background: var(--bg); color: var(--ink);
  padding: 1px 6px; border: 1px solid var(--line-soft); border-radius: 3px;
  font-family: var(--font-mono); font-size: 13px;
}
.msg.ai .bubble pre { background: var(--ink); color: #e5e7eb; padding: 12px; border-radius: var(--radius); overflow-x: auto; font-size: 13px; }
.msg.ai .bubble pre code { background: transparent; color: inherit; padding: 0; border: 0; }
.msg.ai .bubble a { color: var(--ink); text-decoration-thickness: 2px; text-decoration-color: var(--accent); }

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

/* ---------------------------------------------------------------- chips */
.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 0; }
.chip {
  border: 2px solid var(--ink); background: var(--surface); padding: 6px 13px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--ink);
  font-weight: 600; transition: all .12s; box-shadow: var(--shadow-sm); font-family: var(--font-mono);
}
.chip:hover { background: var(--accent); transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.chip:active { transform: translate(1px, 1px); box-shadow: none; }

/* ---------------------------------------------------------------- input */
.chat-input { display: flex; align-items: flex-end; gap: 10px; padding: 14px 20px 18px; }
.chat-input textarea {
  flex: 1; resize: none; border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 12px 14px; font: inherit; font-size: 14.5px; line-height: 1.4;
  max-height: 140px; outline: none; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm); transition: box-shadow .12s;
}
.chat-input textarea:focus { box-shadow: var(--shadow); }
#send-btn {
  width: 46px; height: 46px; flex: 0 0 auto; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--accent); color: var(--ink); font-size: 18px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: all .12s;
}
#send-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
#send-btn:active { transform: translate(1px, 1px); box-shadow: none; }
#send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------- modal */
.modal-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 20, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; animation: fadeIn .15s ease;
}
.drawer-backdrop { justify-content: flex-end; }
.modal {
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius);
  width: min(560px, 92vw); max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 2px solid var(--ink); background: var(--surface); }
.modal-head h3 { margin: 0; font-size: 15px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .03em; }
.modal-close { border: 2px solid var(--ink); background: var(--surface); cursor: pointer; font-size: 16px; color: var(--ink); width: 30px; height: 30px; border-radius: var(--radius); font-weight: 800; box-shadow: var(--shadow-sm); }
.modal-close:hover { background: var(--accent); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 2px solid var(--ink); display: flex; justify-content: flex-end; background: var(--surface); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select, .field textarea {
  border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink); outline: none; background: var(--surface);
  font-family: var(--font); text-transform: none; letter-spacing: normal;
}
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: var(--shadow-sm); }
.field small { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: normal; }
.hint { font-size: 12.5px; color: var(--ink); background: var(--accent); border: 2px solid var(--ink); padding: 8px 12px; border-radius: var(--radius); margin: 0; font-family: var(--font); }

.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cfg-divider { height: 2px; background: var(--ink); margin: 2px 0; }

.btn {
  border: 2px solid var(--ink); cursor: pointer; background: var(--accent); color: var(--ink);
  padding: 10px 18px; border-radius: var(--radius); font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow-sm); transition: all .12s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn-small { padding: 7px 12px; font-size: 13px; }

/* ---------------------------------------------------------------- drawer */
.drawer {
  background: var(--surface); width: min(360px, 90vw); height: 100%;
  display: flex; flex-direction: column; border-left: 2px solid var(--ink);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 2px solid var(--ink); }
.drawer-head h3 { margin: 0; font-size: 15px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .03em; }
.drawer-actions { padding: 12px 18px; }
.history-list { flex: 1; overflow-y: auto; padding: 0 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.history-item {
  border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px 12px; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow-sm); transition: all .12s;
}
.history-item:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.history-item .hi-preview { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .hi-meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; font-family: var(--font-mono); }
.history-item .hi-del { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; }
.history-item .hi-del:hover { color: var(--err); }
.history-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 10px; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--accent); padding: 11px 20px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 200; box-shadow: var(--shadow); max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- anim */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 12px; gap: 12px; }
  .services-panel { max-height: 300px; }
  .services-list { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .service-card { min-width: 240px; flex: 0 0 auto; }
  .chat-panel { height: 72vh; }
  .brand-tag { display: none; }
  .chat-hint { display: none; }
  .cfg-grid { grid-template-columns: 1fr; }
}
