/* claude-mobile - født til lodret telefon. Vanovis-farver, Jost, lys/mørk. */

@font-face {
  font-family: 'Jost';
  src: url('/fonts/Jost-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Jost';
  src: url('/fonts/Jost-Bold.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --green: #173e3c;
  --green-soft: #1f4f4c;
  --salmon: #e8a791;
  --cream: #faf7f2;

  --bg: #f3efe8;
  --bg-elev: #ffffff;
  --fg: #1c2523;
  --fg-muted: #66736f;
  --bubble-user: var(--green);
  --bubble-user-fg: #f2efe9;
  --bubble-ai: #ffffff;
  --border: #ded7cb;
  --code-bg: #14201e;
  --code-fg: #d8e2df;
  --accent: #b3654a;
  --danger: #b3402e;
  --ok: #2e7d5b;
  --card-bg: #fbf9f5;
  --shadow: 0 2px 12px rgba(23, 62, 60, .10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101917;
    --bg-elev: #182420;
    --fg: #e8e4dc;
    --fg-muted: #93a09b;
    --bubble-user: #1f4f4c;
    --bubble-user-fg: #eef0ec;
    --bubble-ai: #182420;
    --border: #29363220;
    --code-bg: #0b1413;
    --code-fg: #cfdad6;
    --accent: #e8a791;
    --card-bg: #1c2b26;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Jost', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 16.5px;
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--fg-muted); }
.pad { padding: 14px; }

.view { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- login ---------- */
#login-view { align-items: center; justify-content: center; background: var(--green); }
.login-box {
  width: min(320px, 86vw); text-align: center; color: var(--cream);
}
.login-logo {
  width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 22px;
  background: var(--salmon); color: var(--green);
  font-size: 42px; font-weight: 700; line-height: 74px;
}
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { opacity: .75; margin-bottom: 22px; font-size: 14px; }
.login-box input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: none;
  font-family: inherit; font-size: 17px; margin-bottom: 10px;
  background: var(--cream); color: var(--green);
}
.login-box button {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: var(--salmon); color: var(--green);
  font-family: inherit; font-size: 17px; font-weight: 700;
}
.login-error { margin-top: 10px; color: #ffb4a2; min-height: 1.4em; font-size: 14px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 2px;
  padding: 8px 6px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--green); color: var(--cream);
  flex: 0 0 auto;
}
.topbar-title { flex: 1; min-width: 0; padding: 0 4px; cursor: pointer; }
.topbar-title .t1 { font-weight: 700; font-size: 17px; line-height: 1.15; }
.topbar-title .caret { font-size: 12px; opacity: .65; }
.ws-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; vertical-align: 2px;
  background: rgba(232, 167, 145, .25); color: var(--salmon);
}
.ws-badge.prod { background: #b3402e; color: #fff; }

/* steder-vælger */
.ws-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ws-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--bg); cursor: pointer;
}
.ws-item.active { border-color: var(--salmon); background: rgba(232, 167, 145, .10); }
.ws-item .wname { font-weight: 700; }
.ws-item .wdir { font-size: 12px; color: var(--fg-muted); font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.ws-item .wwarn { font-size: 12px; color: var(--danger); margin-top: 2px; }
.ws-item .wbadge {
  margin-left: auto; flex: 0 0 auto; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: rgba(23, 62, 60, .12); color: var(--fg-muted);
}
.ws-item .wbadge.prod { background: #b3402e; color: #fff; }

/* vedhæftnings-chips */
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 10px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 6px 4px 12px; font-size: 13px; max-width: 75vw;
}
.chip .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .cx { border: 0; background: none; color: var(--fg-muted); font-size: 13px; padding: 2px 6px; }

/* beslutningsspørgsmål (AskUserQuestion) */
.pq { margin-top: 10px; }
.pqt { font-weight: 700; margin-bottom: 8px; }
.pqopts { display: flex; flex-direction: column; gap: 8px; }
.pqopt {
  text-align: left; padding: 12px; border-radius: 10px; font-size: 15px;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--fg);
}
.pqopt.sel { border-color: var(--salmon); background: rgba(232, 167, 145, .15); font-weight: 700; }

/* samtale arbejder i baggrunden */
.hist-item.working .ht::before {
  content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--salmon); margin-right: 7px; vertical-align: 1px;
  animation: workpulse 1.2s ease-in-out infinite;
}
@keyframes workpulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* mikrofonen lytter */
#btn-mic.mic-live {
  color: #fff; background: #b3402e; border-radius: 50%;
  animation: workpulse 1s ease-in-out infinite;
}
.topbar-title .t2 {
  font-size: 12px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.iconbtn {
  min-width: 42px; height: 42px; border: none; background: transparent;
  color: inherit; font-size: 20px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:active { background: rgba(255, 255, 255, .12); }

/* ---------- beskeder ---------- */
.messages {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 88%; }
.msg.user { align-self: flex-end; }
.msg.ai { align-self: flex-start; max-width: 94%; }

.bubble {
  padding: 10px 14px; border-radius: 18px; word-wrap: break-word; overflow-wrap: break-word;
}
.msg.user .bubble {
  background: var(--bubble-user); color: var(--bubble-user-fg);
  border-bottom-right-radius: 6px; white-space: pre-wrap;
}
.msg.ai .bubble {
  background: var(--bubble-ai); border: 1px solid var(--border);
  border-bottom-left-radius: 6px; box-shadow: var(--shadow);
}

/* markdown i AI-bobler */
.bubble h1, .bubble h2, .bubble h3 { margin: .6em 0 .3em; line-height: 1.25; }
.bubble h1 { font-size: 1.25em; } .bubble h2 { font-size: 1.15em; } .bubble h3 { font-size: 1.05em; }
.bubble p { margin: .45em 0; }
.bubble ul, .bubble ol { margin: .45em 0 .45em 1.3em; }
.bubble li { margin: .18em 0; }
.bubble a { color: var(--accent); }
.bubble blockquote {
  border-left: 3px solid var(--salmon); padding-left: 10px; margin: .5em 0; color: var(--fg-muted);
}
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 4px 8px; font-size: .92em; }
.bubble :first-child { margin-top: 0; }
.bubble :last-child { margin-bottom: 0; }
.bubble code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .88em; background: rgba(23, 62, 60, .10);
  padding: 1px 5px; border-radius: 5px;
}
@media (prefers-color-scheme: dark) {
  .bubble code { background: rgba(232, 167, 145, .14); }
}

/* kodeblokke */
.codewrap {
  position: relative; margin: .55em 0; border-radius: 12px; overflow: hidden;
  background: var(--code-bg);
}
.codewrap pre {
  overflow-x: auto; padding: 12px; padding-top: 30px;
  -webkit-overflow-scrolling: touch;
}
.codewrap pre code {
  background: none; padding: 0; font-size: 13px; line-height: 1.5;
  color: var(--code-fg); font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre;
}
.copybtn {
  position: absolute; top: 4px; right: 4px;
  border: none; border-radius: 8px; padding: 3px 10px;
  background: rgba(255, 255, 255, .12); color: #cfd8d5;
  font-family: inherit; font-size: 12px;
}
.copybtn:active { background: rgba(255, 255, 255, .3); }
.codelang {
  position: absolute; top: 6px; left: 12px; font-size: 11px; color: #7f938e;
  font-family: ui-monospace, monospace;
}

/* ---------- tool-kort ---------- */
.toolcard {
  align-self: flex-start; max-width: 94%; width: fit-content; min-width: 230px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; font-size: 14.5px;
}
.toolcard-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
}
.toolcard-head .ticon { font-size: 15px; flex: 0 0 auto; }
.toolcard-head .tname { font-weight: 700; flex: 0 0 auto; }
.toolcard-head .tsum {
  flex: 1; min-width: 0; color: var(--fg-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px;
}
.toolcard-head .tstate { flex: 0 0 auto; font-size: 13px; }
.tstate.run { color: var(--accent); animation: pulse 1.2s infinite; }
.tstate.ok { color: var(--ok); }
.tstate.err { color: var(--danger); }
.toolcard details { border-top: 1px dashed var(--border); }
.toolcard summary {
  padding: 6px 12px; color: var(--fg-muted); font-size: 13px; cursor: pointer;
  list-style: none;
}
.toolcard summary::before { content: '▸ '; }
.toolcard details[open] summary::before { content: '▾ '; }
.toolcard .tdetail {
  padding: 0 12px 10px; overflow-x: auto;
}
.toolcard .tdetail pre {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
  background: var(--code-bg); color: var(--code-fg);
  padding: 10px; border-radius: 10px; max-height: 40vh; overflow: auto;
}

/* godkendelses-kort */
.permcard {
  align-self: stretch; background: var(--card-bg);
  border: 2px solid var(--salmon); border-radius: 16px; padding: 12px;
}
.permcard .ptitle { font-weight: 700; margin-bottom: 4px; }
.permcard .pdesc {
  font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  background: var(--code-bg); color: var(--code-fg);
  padding: 10px; border-radius: 10px; margin: 8px 0;
  white-space: pre-wrap; word-break: break-word; max-height: 30vh; overflow: auto;
}
.permbtns { display: flex; gap: 10px; margin-top: 10px; }
.permbtns button {
  flex: 1; padding: 13px; border: none; border-radius: 12px;
  font-family: inherit; font-size: 16px; font-weight: 700;
}
.perm-allow { background: var(--green); color: var(--cream); }
.perm-deny { background: transparent; color: var(--danger); border: 1.5px solid var(--danger) !important; }
.permcard.done { opacity: .62; border-color: var(--border); }
.permcard .pverdict { font-weight: 700; margin-top: 6px; }

/* arbejder-indikator */
.working {
  align-self: flex-start; display: flex; align-items: center; gap: 8px;
  color: var(--fg-muted); font-size: 14px; padding: 2px 6px;
}
.working .dots { display: inline-flex; gap: 3px; }
.working .dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--salmon);
  animation: bounce 1.2s infinite;
}
.working .dots span:nth-child(2) { animation-delay: .15s; }
.working .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* fejl + info */
.sysline {
  align-self: center; text-align: center; color: var(--fg-muted); font-size: 13px;
  padding: 2px 10px;
}
.sysline.error { color: var(--danger); }

/* tom tilstand */
.empty-state {
  margin: auto; text-align: center; color: var(--fg-muted); padding: 30px 20px;
}
.empty-state .big { font-size: 44px; margin-bottom: 10px; }

/* ---------- inputbar ---------- */
.inputbar {
  flex: 0 0 auto; padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.inputwrap {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--bg-elev); border: 1.5px solid var(--border);
  border-radius: 22px; padding: 5px 6px 5px 4px;
}
.at-btn { color: var(--fg-muted); font-weight: 700; min-width: 38px; height: 38px; }
#input {
  flex: 1; border: none; background: transparent; resize: none; outline: none;
  font-family: inherit; font-size: 16.5px; color: var(--fg);
  max-height: 9.5em; line-height: 1.4; padding: 8px 0;
}
.sendbtn, .stopbtn {
  min-width: 40px; height: 40px; border: none; border-radius: 50%;
  font-size: 17px; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.sendbtn { background: var(--green); color: var(--cream); }
.sendbtn:disabled { opacity: .35; }
.stopbtn { background: var(--danger); color: #fff; }

.jump-down {
  position: fixed; right: 14px; bottom: calc(86px + env(safe-area-inset-bottom));
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--green); color: var(--cream);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); z-index: 30; font-size: 19px;
}

/* ---------- skuffer ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 18, .45); z-index: 40;
}
.drawer {
  position: fixed; top: 0; bottom: 0; width: min(320px, 86vw); z-index: 50;
  background: var(--bg-elev); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 0 30px rgba(0, 0, 0, .35);
  transition: transform .22s ease;
}
.drawer.left { left: 0; }
.drawer.right { right: 0; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 8px 16px;
}
.drawer-head h2 { font-size: 18px; }
.drawer-head .iconbtn { color: var(--fg-muted); }

.newchat-btn {
  margin: 2px 14px 10px; padding: 12px; border: none; border-radius: 12px;
  background: var(--green); color: var(--cream);
  font-family: inherit; font-size: 15.5px; font-weight: 700;
}
.history-list { flex: 1; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
.hist-item {
  padding: 11px 16px; border-top: 1px solid var(--border); cursor: pointer;
}
.hist-item.active { background: rgba(232, 167, 145, .16); border-left: 3px solid var(--salmon); }
.hist-item .ht {
  font-size: 14.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hist-item .hd { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }

.files-hint {
  padding: 0 16px 8px; font-size: 13px; color: var(--accent);
}
.file-tree { flex: 1; overflow-y: auto; padding: 0 6px calc(10px + env(safe-area-inset-bottom)); font-size: 14.5px; }
.ft-row {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 9px;
  cursor: pointer; word-break: break-all;
}
.ft-row:active { background: rgba(232, 167, 145, .14); }
.ft-row .fticon { flex: 0 0 auto; font-size: 13px; }
.ft-children { margin-left: 16px; border-left: 1px solid var(--border); padding-left: 2px; }

/* ---------- fil-visning (sheet) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 6px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--green); color: var(--cream);
}
.sheet-title {
  flex: 1; min-width: 0; font-size: 14px; font-family: ui-monospace, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left;
}
.sheet-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-body pre {
  padding: 12px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); min-width: max-content;
}
.sheet-body code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; line-height: 1.5;
  white-space: pre;
}

/* ---------- menu ---------- */
.menu-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--bg-elev); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0, 0, 0, .3);
}
.menu-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.menu-row label { font-weight: 700; font-size: 14px; }
.menu-row select {
  padding: 11px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--fg); font-family: inherit; font-size: 15px;
}
.menu-note { font-size: 13px; color: var(--fg-muted); margin-bottom: 16px; }
.menu-danger {
  width: 100%; padding: 12px; border: 1.5px solid var(--danger); border-radius: 12px;
  background: transparent; color: var(--danger); font-family: inherit; font-size: 15.5px; font-weight: 700;
}
.menu-version { text-align: center; color: var(--fg-muted); font-size: 12px; margin-top: 14px; }

/* hljs-tema (mørkt, matcher --code-bg) */
.hljs-comment, .hljs-quote { color: #6f8a84; font-style: italic; }
.hljs-keyword, .hljs-selector-tag { color: #e8a791; }
.hljs-string, .hljs-attr { color: #a3c9a8; }
.hljs-number, .hljs-literal { color: #d9b08c; }
.hljs-title, .hljs-name, .hljs-built_in { color: #8fc7bf; }
.hljs-variable, .hljs-template-variable { color: #d8e2df; }
.hljs-section, .hljs-meta { color: #c9a3e8; }
