/* ===========================
   drkl.my.id — unified theme (gruvbox material hard)
   =========================== */

/* --- Gruvbox Material Dark (hard contrast) --- */
[data-theme="dark"] {
  --bg: #1d2021;
  --panel: #282828;
  --panel2: #32302f;
  --border: #665c54;
  --text: #d4be98;
  --muted: #a89984;
  --blue: #83a598;
  --green: #b8bb26;
  --yellow: #fe8019;
  --red: #fb4934;
  --cyan: #8ec07c;
  --orange: #fe8019;
  --purple: #d3869b;
  --btn-bg: #83a598;
  --btn-text: #1d2021;
  --btn-hover: #b8bb26;
  --accent: #83a598;
  --term-shadow: 0 20px 50px rgba(0,0,0,.6), 0 0 40px rgba(131,165,152,.15);
  --banner-glow: rgba(184,187,38,.35);
  --code-bg: rgba(0,0,0,.5);
}

/* --- Gruvbox Material Light (hard contrast) --- */
[data-theme="light"] {
  --bg: #f9f5d7;
  --panel: #fbf1c7;
  --panel2: #ebdbb2;
  --border: #a89984;
  --text: #3c3836;
  --muted: #7c6f64;
  --blue: #076678;
  --green: #98971a;
  --yellow: #d65d0e;
  --red: #cc241d;
  --cyan: #427b58;
  --orange: #d65d0e;
  --purple: #8f3f71;
  --btn-bg: #076678;
  --btn-text: #f9f5d7;
  --btn-hover: #458588;
  --accent: #076678;
  --term-shadow: 0 20px 50px rgba(0,0,0,.15);
  --banner-glow: rgba(152,151,26,.25);
  --code-bg: rgba(0,0,0,.12);
}

/* --- Base --- */
* { box-sizing: border-box; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

html, body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  transition: background .3s, color .3s;
  -webkit-text-size-adjust: 100%;
}
body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  min-height: 100vh;
  min-height: 100dvh;
}
.wrap {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  min-height: fit-content;
}
a { color: var(--blue); transition: color .15s; }
a:hover { filter: brightness(1.2); }

/* --- Header --- */
.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}
header.site { margin-bottom: 14px; }
footer.site { margin-top: 14px; justify-content: center; gap: 18px; }
.site .brand { color: var(--text); font-weight: 700; font-size: 15px; }
.site .brand .dim { color: var(--muted); font-weight: 400; }
.site nav { display: flex; gap: 16px; align-items: center; }
.site nav a { color: var(--muted); font-size: 13px; text-decoration: none; }
.site nav a:hover { color: var(--blue); }
footer.site a { color: var(--muted); font-size: 13px; text-decoration: none; }
footer.site a:hover { color: var(--blue); }
.sep { color: var(--border); }

/* --- Theme button --- */
.theme-btn {
  background: none; border: none; cursor: pointer; font-size: 18px;
  padding: 2px 6px; border-radius: 4px; line-height: 1; color: var(--muted);
  transition: color .15s, background .15s; width: auto; flex-shrink: 0;
}
.theme-btn:hover { background: var(--panel2); color: var(--blue); }
.theme-btn.switching { animation: themeSpin .4s ease; }
@keyframes themeSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.3); }
  100% { transform: rotate(360deg) scale(1); }
}

/* --- Terminal --- */

.term {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--term-shadow);
  overflow: hidden;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: var(--red); }
.dot.y { background: var(--yellow); }
.dot.g { background: var(--green); }
.titlebar span { margin-left: 8px; color: var(--muted); font-size: 13px; }

#screen {
  height: calc(100vh - 220px);
  height: calc(100dvh - 220px);
  max-height: 600px;
  min-height: 200px;
  overflow-y: auto;
  padding: 18px 20px;
  line-height: 1.45;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  user-select: text;
  -webkit-user-select: text;
}
#screen::-webkit-scrollbar { width: 8px; }
#screen::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::selection { background: var(--blue); color: var(--bg); }

/* --- Terminal text --- */
.row { white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text; }
.prompt { color: var(--green); }
.cmd { color: var(--text); }
.muted { color: var(--muted); }
.err { color: var(--red); }
.ok { color: var(--yellow); }
.dir { color: var(--blue); }
.blue { color: var(--blue); }
pre { margin: 0 0 4px; font-family: inherit; font-size: 12px; line-height: 1.25; }
pre.neofetch { font-size: 13px; line-height: 1.4; }

/* Neofetch ASCII art coloring */
[data-theme="dark"] pre.neofetch {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
}
pre.neofetch .ascii-line-0 { color: var(--blue); }
pre.neofetch .ascii-line-1 { color: var(--blue); }
pre.neofetch .ascii-line-2 { color: var(--cyan); }
pre.neofetch .ascii-line-3 { color: var(--cyan); }
pre.neofetch .ascii-line-4 { color: var(--green); }
pre.neofetch .ascii-line-5 { color: var(--green); }
pre.neofetch .ascii-line-6 { color: var(--yellow); }
pre.neofetch .ascii-line-7 { color: var(--yellow); }
pre.neofetch .ascii-line-8 { color: var(--orange); }
pre.neofetch .ascii-line-9 { color: var(--orange); }
pre.neofetch .ascii-line-10 { color: var(--red); }
pre.neofetch .ascii-line-11 { color: var(--red); }
.chat-reply { color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.5; user-select: text; -webkit-user-select: text; }
.chat-you { color: var(--green); font-weight: 700; }
.chat-ai { color: var(--cyan); font-weight: 700; }
.chat-code {
  display: block; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 8px 12px; margin: 4px 0 8px;
  font-size: 13px; line-height: 1.4; overflow-x: auto;
  white-space: pre;
}
.chat-inline {
  background: var(--code-bg); padding: 1px 5px; border-radius: 3px;
  font-size: 13px; color: var(--yellow);
}
.chat-bold { color: var(--yellow); font-weight: 700; }
.chat-italic { color: var(--muted); font-style: italic; }
.chat-code-lang {
  display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.chat-h1 { color: var(--yellow); font-weight: 700; }
.chat-h2 { color: var(--blue); font-weight: 700; }
.chat-h3 { color: var(--cyan); font-weight: 700; }
.chat-quote {
  display: block; border-left: 3px solid var(--border);
  padding-left: 10px; color: var(--muted); margin: 2px 0;
}
.chat-bullet, .chat-num { color: var(--cyan); font-weight: 700; margin-right: 4px; }
.chat-task { color: var(--text); }
.chat-task.done { color: var(--muted); text-decoration: line-through; }

/* --- Chat tables --- */
.chat-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.4;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-table th,
.chat-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.chat-table th {
  background: var(--panel2);
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.chat-table tr:nth-child(even) td {
  background: var(--panel2);
}
.chat-table td {
  color: var(--text);
}
@media (max-width: 480px) {
  .chat-table {
    font-size: 12px;
    margin: 6px -12px;
    padding: 0 12px 6px;
    border-radius: 0;
  }
  .chat-table th,
  .chat-table td {
    padding: 5px 8px;
    min-width: max-content;
  }
}

/* --- Input --- */
#inputline { display: flex; align-items: center; gap: 6px; }
#inputline .prompt { flex-shrink: 0; }
.inputwrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#cmdInput {
  width: 100%; padding: 0; background: transparent; border: none; outline: none;
  color: var(--text); font-family: inherit; font-size: 15px; caret-color: var(--blue);
  position: relative; z-index: 1;
}
#suggest {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0;
  display: flex; align-items: center;
  color: var(--muted); opacity: .6; pointer-events: none;
  white-space: pre; overflow: hidden; visibility: hidden;
}

/* --- Suggestion list --- */
#suggestList {
  display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 2px 0 6px; font-size: 13px;
}
#suggestList span {
  cursor: pointer; color: var(--blue); border-radius: 3px; padding: 0 4px;
  transition: background .12s, color .12s;
}
#suggestList span:hover { background: var(--panel2); color: var(--cyan); }
#suggestList span.active { background: var(--border); }
#suggestList:empty { display: none; }

/* --- Help list --- */
.helplist { margin: 4px 0 0; padding-left: 18px; }
.helplist li { margin: 2px 0; }

/* --- Chat welcome box --- */
.chat-welcome {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 8px 0;
  background: var(--panel2);
}
.chat-welcome .chat-welcome-title {
  color: var(--green);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 10px;
}
.chat-welcome-cmds {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 14px;
}
.chat-welcome-cmds .cmd-name { color: var(--text); }
.chat-welcome-cmds .cmd-desc { color: var(--muted); }

/* --- Chat help table --- */
.chat-help {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 16px;
  font-size: 14px;
  margin: 4px 0;
}
.chat-help .cmd-name { color: var(--text); }
.chat-help .cmd-desc { color: var(--muted); }

/* --- Mobile --- */
@media (max-width: 480px) {
  body { padding: 0; font-size: 14px; align-items: flex-start; min-height: 100vh; min-height: 100dvh; }
  .wrap { max-width: 100%; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
  header.site { padding: 8px 12px 0; margin-bottom: 8px; }
  footer.site { padding: 0 12px 8px; margin-top: 8px; gap: 12px; }
  header.site nav { gap: 8px; }
  .site .brand { font-size: 14px; }
  .site nav a { font-size: 12px; padding: 4px 0; }
  footer.site a { font-size: 12px; }
  #screen {
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
    padding: 12px;
    min-height: 200px;
    max-height: none;
  }
  .titlebar { padding: 8px 12px; }
  .titlebar span { display: inline; font-size: 11px; }
  .dot { width: 9px; height: 9px; }
  #cmdInput { font-size: 16px; padding: 8px 0; }
  #inputline { padding: 0 12px 10px; gap: 8px; }
  .term { border-radius: 0; border-left: none; border-right: none; border-bottom: none; }
  pre { font-size: 11px; padding: 6px 8px; }
  .chat-help { font-size: 12px; gap: 2px 10px; }
  .chat-welcome { padding: 10px 12px; }
  .chat-welcome-title { font-size: 14px !important; }
  .chat-welcome-cmds { font-size: 12px; gap: 3px 10px; }
  .chat-reply { font-size: 13px; line-height: 1.5; }
  .row { font-size: 13px; }
}

@media (max-width: 360px) {
  body { font-size: 13px; }
  .site .brand { font-size: 13px; }
  #screen { padding: 10px; height: calc(100vh - 130px); height: calc(100dvh - 130px); }
  #cmdInput { font-size: 16px; }
  .titlebar { padding: 6px 10px; }
  .titlebar span { font-size: 10px; }
  .dot { width: 8px; height: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-btn.switching { animation: none; }
}

/* Syntax highlighting for code blocks in chat */
.hl-kw { color: var(--purple); font-weight: 600; }
.hl-str { color: var(--green); }
.hl-comment { color: var(--muted); font-style: italic; }
.hl-num { color: var(--orange); }
.hl-func { color: var(--blue); }
.hl-type { color: var(--yellow); font-weight: 600; }
.hl-decorator { color: var(--cyan); }

/* Terminal text editor */
.editor-line { font-family: inherit; white-space: pre; }
.editor-cursor {
  display: inline-block;
  width: 8px;
  height: 1.2em;
  background: var(--blue);
  animation: blink 1s infinite;
  vertical-align: text-bottom;
  margin: 0 1px;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
input[placeholder*="Editing mode"] {
  border-bottom: 2px solid var(--blue);
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
  #cmdInput {
    font-size: 16px !important;
  }
}
