:root {
  --bg: #0e1218;
  --bg-elev: #161c26;
  --bg-rail: #121820;
  --ink: #e8edf4;
  --muted: #8b97a8;
  --line: rgba(232, 237, 244, 0.1);
  --accent: #3ecfbf;
  --accent-dim: rgba(62, 207, 191, 0.14);
  --warn: #e8a54b;
  --user: #243044;
  --assistant: #1a222e;
  --radius: 14px;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(62, 207, 191, 0.16), transparent 55%),
    radial-gradient(700px 420px at 90% 10%, rgba(72, 110, 180, 0.18), transparent 50%),
    linear-gradient(165deg, #0c1016 0%, #121a24 45%, #0e1218 100%);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  min-height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem 1.25rem;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-rail) 88%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 10px;
  background: var(--accent);
  color: #06221f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-sub {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%238b97a8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")
    right 0.85rem center / 12px no-repeat;
  color: var(--ink);
  font: 500 0.95rem var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  padding: 0.7rem 2.2rem 0.7rem 0.85rem;
  outline: none;
}

.auth-box {
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
}

.auth-label {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.auth-user {
  margin: 0.35rem 0 0.65rem;
  font-size: 0.88rem;
  font-weight: 500;
  word-break: break-all;
}

.auth-btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  background: var(--accent);
  color: #06221f;
  font: 600 0.88rem var(--font-body);
  cursor: pointer;
}

.auth-btn.ghost {
  margin-top: 0.4rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.auth-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gate {
  margin: auto;
  text-align: center;
  max-width: 22rem;
  animation: rise 0.45s ease both;
}

.gate h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.gate p {
  color: var(--muted);
  line-height: 1.45;
}

.field-note {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  line-height: 1.35;
  word-break: break-all;
}

.field select:disabled {
  opacity: 0.95;
  cursor: default;
}

.field select:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.pillars {
  display: grid;
  gap: 0.5rem;
}

.pillar {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
}

.pillar span {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
}

.pillar small {
  color: var(--muted);
  font-size: 0.75rem;
}

.pillar.on {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: linear-gradient(135deg, var(--accent-dim), transparent 70%);
}

.pillar.dim {
  opacity: 0.55;
}

.hints-title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.hint {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--ink);
  font: 400 0.85rem/1.35 var(--font-body);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.hint:hover {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--accent-dim);
  transform: translateX(2px);
}

.foot {
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

.linkish {
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stage {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 1.5rem 1.5rem 1.1rem;
}

.top {
  margin-bottom: 1rem;
  animation: rise 0.55s ease both;
}

.top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.lede {
  margin: 0.45rem 0 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.lede strong {
  color: var(--accent);
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.25rem 0.15rem 1rem;
  scroll-behavior: smooth;
}

.bubble {
  max-width: min(640px, 92%);
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
  animation: rise 0.35s ease both;
}

.bubble.user {
  align-self: flex-end;
  background: var(--user);
  border: 1px solid var(--line);
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--assistant);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.bubble.md {
  white-space: normal;
}

.bubble.md > :first-child {
  margin-top: 0;
}

.bubble.md > :last-child {
  margin-bottom: 0;
}

.bubble.md p {
  margin: 0.55em 0;
}

.bubble.md h1,
.bubble.md h2,
.bubble.md h3,
.bubble.md h4 {
  margin: 0.85em 0 0.4em;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--ink);
}

.bubble.md h1 {
  font-size: 1.2rem;
}
.bubble.md h2 {
  font-size: 1.1rem;
}
.bubble.md h3,
.bubble.md h4 {
  font-size: 1rem;
}

.bubble.md ul,
.bubble.md ol {
  margin: 0.45em 0;
  padding-left: 1.35em;
}

.bubble.md li {
  margin: 0.2em 0;
}

.bubble.md li > ul,
.bubble.md li > ol {
  margin: 0.15em 0;
}

.bubble.md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bubble.md a:hover {
  color: color-mix(in srgb, var(--accent) 80%, white);
}

.bubble.md strong {
  font-weight: 600;
  color: var(--ink);
}

.bubble.md em {
  font-style: italic;
}

.bubble.md blockquote {
  margin: 0.6em 0;
  padding: 0.15em 0 0.15em 0.85em;
  border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--muted);
}

.bubble.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.9em 0;
}

.bubble.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border: 1px solid var(--line);
}

.bubble.md pre {
  margin: 0.65em 0;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 85%, #000);
  border: 1px solid var(--line);
}

.bubble.md pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
}

.bubble.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.65em 0;
  font-size: 0.88rem;
  overflow-x: auto;
  display: block;
}

.bubble.md th,
.bubble.md td {
  border: 1px solid var(--line);
  padding: 0.4em 0.65em;
  text-align: left;
}

.bubble.md th {
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  font-weight: 600;
}

.bubble.md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.worklogs-table-wrap {
  align-self: flex-start;
  max-width: min(720px, 96%);
  width: 100%;
  overflow-x: auto;
  margin: 0.15rem 0 0.75rem;
  animation: rise 0.35s ease both;
}

.worklogs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  background: var(--assistant);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.worklogs-table th,
.worklogs-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.45em 0.7em;
  text-align: left;
  vertical-align: top;
}

.worklogs-table .worklog-date,
.worklogs-table .worklog-hours,
.worklogs-table th:nth-child(1),
.worklogs-table th:nth-child(2) {
  white-space: nowrap;
}

.worklogs-table .worklog-personne {
  white-space: nowrap;
}

.worklogs-table th {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  font-weight: 600;
  white-space: nowrap;
}

.worklogs-table tr:last-child td {
  border-bottom: 0;
}

.worklogs-table .worklog-desc a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.worklogs-table .worklog-desc a:hover {
  opacity: 0.9;
}

.worklogs-empty {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--assistant);
  color: color-mix(in srgb, var(--ink) 70%, transparent);
  font-size: 0.9rem;
}

.bubble.error {
  align-self: stretch;
  background: rgba(200, 80, 70, 0.12);
  border: 1px solid rgba(200, 80, 70, 0.35);
  color: #f0c4c0;
}

.tools {
  align-self: flex-start;
  max-width: min(640px, 92%);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  animation: rise 0.35s ease both;
}

.tool-chip {
  font-size: 0.72rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--assistant);
  border: 1px solid var(--line);
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.2);
  animation: rise 0.65s 0.1s ease both;
}

.composer textarea {
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 400 1rem/1.45 var(--font-body);
  max-height: 160px;
  padding: 0.35rem 0.25rem;
}

.composer textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}

.composer button[type="submit"] {
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #06221f;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}

.composer button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.composer button[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 22rem;
  animation: rise 0.5s ease both;
}

.empty p {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .hints,
  .pillars {
    display: none;
  }

  .stage {
    min-height: auto;
    height: calc(100dvh - 180px);
  }
}
