:root {
  color-scheme: light;
  font-family: ui-rounded, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #173a36;
  background: #fff8e8;
  font-synthesis: none;
  --ink: #173a36;
  --muted: #5d6c65;
  --canvas: #fff8e8;
  --surface: #fffdf8;
  --primary: #176b63;
  --primary-dark: #0e514c;
  --coral: #f27669;
  --sunflower: #f6c84a;
  --sky: #76c7e5;
  --leaf: #65a85d;
  --lavender: #aa92d7;
  --line: #d9ddca;
  --shadow: 0 0.75rem 2rem rgb(49 76 62 / 11%);
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 78rem;
  min-height: 100vh;
  padding: 1rem 1.25rem 3rem;
  background:
    radial-gradient(circle at 7% 2%, rgb(118 199 229 / 22%), transparent 15rem),
    radial-gradient(circle at 94% 11%, rgb(242 118 105 / 17%), transparent 13rem),
    linear-gradient(180deg, #fffaf0 0%, var(--canvas) 68%, #f7f4de 100%);
}

button, input, textarea { font: inherit; }

button {
  min-height: 2.75rem;
  padding: 0.58rem 1rem;
  border: 1px solid #bcc8bb;
  border-radius: 1rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0.18rem 0.45rem rgb(49 76 62 / 7%);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease,
    border-color 140ms ease, background-color 140ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f5fbf5;
  box-shadow: 0 0.35rem 0.85rem rgb(49 76 62 / 12%);
  transform: translateY(-1px);
}
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #7042a3;
  outline-offset: 3px;
}
button.primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}
button.primary:hover:not(:disabled) { border-color: var(--primary-dark); background: var(--primary-dark); }
button.quiet { padding-left: 0; border-color: transparent; background: transparent; box-shadow: none; }
button:disabled, textarea:disabled { cursor: wait; opacity: 0.58; }
input:disabled { cursor: wait; opacity: 0.58; }

.site-header, .section-heading, .task-heading-row, .composer-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.site-header {
  padding: 0.65rem 0.75rem;
  border: 1px solid rgb(217 221 202 / 85%);
  border-radius: 1.35rem;
  background: rgb(255 253 248 / 88%);
  box-shadow: 0 0.35rem 1.2rem rgb(49 76 62 / 8%);
}

.site-header nav { display: flex; gap: 0.5rem; }
.site-header nav button { background: #fffdf8; }
.site-header #logout { border-color: #efb0aa; color: #7f302a; background: #fff5f2; }

.account-chip {
  margin: 0 0 0 auto;
  padding: 0.45rem 0.7rem;
  border: 1px solid #b6dceb;
  border-radius: 999px;
  color: #315b69;
  background: #eefaff;
  font-size: 0.9rem;
}

.account-chip strong { color: var(--ink); }

.brand {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-color: transparent;
  background: transparent;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: none;
}

.brand-mark {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50% 50% 46% 54%;
  color: #7c4c00;
  background: var(--sunflower);
  box-shadow: inset 0 -0.16rem 0 rgb(197 129 13 / 18%);
  place-items: center;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.8rem; font-size: clamp(1.85rem, 5vw, 2.85rem); line-height: 1.08; letter-spacing: -0.025em; }
h2 { margin-bottom: 0.65rem; }

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.security-banner {
  margin: 1rem 0 0;
  padding: 0.65rem 0.9rem;
  border: 1px solid #d3a62c;
  border-radius: 1rem;
  color: #5f4305;
  background: #fff4c9;
  font-size: 0.9rem;
  font-weight: 750;
  text-align: center;
}

.connection-status {
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid #efaaa2;
  border-radius: 1rem;
  color: #782b26;
  background: #fff0ed;
  font-weight: 700;
}

main { margin-top: 2.25rem; }
.login-view { display: grid; min-height: calc(100vh - 6rem); place-items: center; }
.login-panel {
  position: relative;
  display: grid;
  width: min(100%, 25rem);
  gap: 0.6rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1.75rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-panel::before {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin: -3.5rem auto 0.4rem;
  border: 0.3rem solid var(--surface);
  border-radius: 50%;
  color: #7c4c00;
  background: var(--sunflower);
  box-shadow: 0 0.35rem 0.8rem rgb(49 76 62 / 12%);
  content: "✿";
  font-size: 1.45rem;
  place-items: center;
}
.login-panel h1 { margin-bottom: 0.2rem; }
.login-panel label { margin-top: 0.35rem; font-weight: 750; }
.login-panel button { margin-top: 0.65rem; }
.login-panel .password-toggle {
  width: fit-content;
  min-height: 2.35rem;
  margin-top: 0;
  padding: 0.35rem 0.7rem;
  border-color: #b6dceb;
  color: var(--primary-dark);
  background: #eefaff;
  font-size: 0.9rem;
  font-weight: 750;
}
.hero {
  overflow: hidden;
  max-width: 56rem;
  margin: 3rem auto 4rem;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: linear-gradient(145deg, #fffdf8 20%, #fff7db 100%);
  box-shadow: var(--shadow);
  text-align: center;
}
.hero textarea { min-height: 8rem; padding: 1rem; border-radius: 1.15rem; box-shadow: 0 0.55rem 1.4rem rgb(49 76 62 / 9%); text-align: left; }
.garden-illustration { display: block; width: min(100%, 35rem); height: auto; margin: -0.35rem auto 0.4rem; }
.garden-sun { fill: var(--sunflower); }
.garden-hill-back { fill: #dff2d7; }
.garden-hill-front { fill: #bedd9d; }
.garden-stem path { fill: none; stroke: #4c8b50; stroke-linecap: round; stroke-width: 5; }
.garden-stem ellipse { fill: var(--leaf); }
.garden-flower-coral { fill: var(--coral); }
.garden-flower-lavender { fill: var(--lavender); }
.garden-flower-sky { fill: var(--sky); }
.garden-flower-center { fill: var(--sunflower); }
.home-section { margin: 0 0 2.5rem; }
.home-section > .section-heading { padding: 0 0.25rem; }

textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #91a49a;
  border-radius: 1rem;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
}

input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #91a49a;
  border-radius: 1rem;
  color: var(--ink);
  background: var(--surface);
}

.composer-actions { min-height: 3.2rem; align-items: start; margin-top: 0.65rem; }
.composer-actions button { flex: 0 0 auto; }
.inline-error { margin: 0.5rem 0 0; color: #8a2f29; font-weight: 800; text-align: left; }
.task-list, .schedule-list { display: grid; gap: 0.8rem; }
.task-list:empty::before, .schedule-list:empty::before, .transcript:empty::before { color: var(--muted); content: "Hier gibt es noch nichts."; }

.task-card {
  width: 100%;
  padding: 1.05rem 1.2rem;
  border: 1px solid var(--line);
  border-left: 0.32rem solid var(--sky);
  border-radius: 1.2rem;
  background: var(--surface);
  box-shadow: 0 0.3rem 1rem rgb(49 76 62 / 6%);
  text-align: left;
}
.task-card:nth-child(3n + 2) { border-left-color: var(--coral); }
.task-card:nth-child(3n) { border-left-color: var(--lavender); }

.task-card-heading, .task-card-meta, .schedule-row, .task-indicators {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}

.task-card-title { margin: 0; font-size: 1.05rem; font-weight: 800; }
.task-preview { margin: 0.45rem 0 0.7rem; color: #4e625b; }
.task-card-meta, .schedule-detail, .muted { color: var(--muted); font-size: 0.86rem; }

.working-indicator, .schedule-chip {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  width: fit-content;
  padding: 0.28rem 0.55rem;
  border-radius: 99rem;
  color: #24512d;
  background: #e1f2dc;
  font-size: 0.78rem;
  font-weight: 800;
}

.working-indicator::before { width: 0.48rem; height: 0.48rem; border-radius: 50%; background: var(--leaf); content: ""; }
.schedule-chip { color: #674a08; background: #fff0bd; }
.schedule-card { padding: 1rem 1.1rem; border: 1px solid #ead89c; border-left: 0.35rem solid var(--sunflower); border-radius: 1.15rem; background: var(--surface); box-shadow: 0 0.25rem 0.8rem rgb(49 76 62 / 5%); }
.schedule-row p { margin-bottom: 0; }
.schedule-reason { margin: 0.35rem 0 0; color: #4e625b; }
.back-button { margin-bottom: 1rem; }
.task-heading-row { align-items: end; margin-bottom: 1rem; }
.task-heading-row h1 { margin-bottom: 0; }
.task-indicators { justify-content: end; flex-wrap: wrap; }
.task-schedule { max-width: 24rem; }
.task-schedule .schedule-reason { margin-bottom: 0; text-align: right; }

.task-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
}

.task-pane, .memory-panel { min-width: 0; border: 1px solid var(--line); border-radius: 1.25rem; background: var(--surface); box-shadow: 0 0.35rem 1.1rem rgb(49 76 62 / 6%); }
.chat-pane { display: flex; min-height: 34rem; max-height: calc(100vh - 13rem); flex-direction: column; }

.transcript {
  display: flex;
  overflow-y: auto;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
}

.turn { max-width: 88%; padding: 0.85rem 1rem; border-radius: 1.1rem; overflow-wrap: anywhere; }
.turn-user { align-self: end; background: #e1f2dc; }
.turn-assistant { align-self: start; border: 1px solid #d8dfd3; background: #fbfcf6; }
.turn-system { align-self: stretch; max-width: none; border: 1px solid #e7cb72; color: #604607; background: #fff6d5; }

.turn-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.turn .markdown-output { margin: 0; padding: 0; border: 0; background: transparent; }
.turn .markdown-output > :last-child { margin-bottom: 0; }
.task-composer { flex: 0 0 auto; padding: 0.95rem; border-top: 1px solid var(--line); }
.task-composer textarea { margin: 0; }
.document-pane, .memory-panel { overflow-y: auto; padding: 1.1rem; }
.document-pane { max-height: calc(100vh - 13rem); }
.pane-heading { padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.markdown-output { overflow-wrap: anywhere; }
.markdown-output a {
  color: #075f78;
  cursor: pointer;
  font-weight: 750;
  text-decoration-color: #58a8bd;
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.16em;
}
.markdown-output a::after {
  color: var(--primary);
  content: " ↗";
  font-size: 0.82em;
  font-weight: 900;
}
.markdown-output a:hover { color: #06485b; }
.markdown-output a:focus-visible {
  border-radius: 0.2rem;
  outline: 3px solid #7042a3;
  outline-offset: 3px;
}
.markdown-output pre { overflow-x: auto; padding: 0.8rem; border-radius: 0.75rem; background: #eef0e7; }
.markdown-output code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.read-only-document:empty::before { color: var(--muted); content: "PAI hat noch nichts notiert."; }
.mobile-tabs { display: none; }

.external-link-dialog {
  width: min(calc(100% - 2rem), 34rem);
  max-height: min(90vh, 46rem);
  overflow: auto;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1.2rem 4rem rgb(24 49 42 / 28%);
}
.external-link-dialog::backdrop {
  background: rgb(23 58 54 / 48%);
  backdrop-filter: blur(2px);
}
.external-link-dialog h2 { margin-bottom: 0.65rem; }
.external-link-flower {
  display: grid;
  float: right;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  color: #7c4c00;
  background: var(--sunflower);
  font-size: 1.25rem;
  place-items: center;
}
.external-link-detail {
  display: grid;
  gap: 0.15rem;
  margin: 1.1rem 0 0.8rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #b6dceb;
  border-radius: 0.9rem;
  background: #eefaff;
}
.external-link-detail span,
.external-link-address-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.external-link-address-label { margin-bottom: 0.35rem; }
.external-link-url {
  display: block;
  overflow: auto;
  max-height: 9rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.75rem;
  background: #eef0e7;
  overflow-wrap: anywhere;
  white-space: normal;
}
.external-link-warning {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid #e7cb72;
  border-radius: 0.8rem;
  color: #604607;
  background: #fff6d5;
  font-weight: 700;
}
.external-link-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: end;
  margin-top: 1.25rem;
}
.external-link-open {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.58rem 1rem;
  border: 1px solid var(--primary);
  border-radius: 1rem;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
  text-decoration: none;
}
.external-link-open:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.external-link-open:focus-visible { outline: 3px solid #7042a3; outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hidden { display: none !important; }

@media (max-width: 48rem) {
  body { padding: 0.75rem 0.85rem 2rem; }
  .hero { margin: 2.25rem auto 3rem; }
  .task-heading-row { align-items: start; flex-direction: column; }
  .task-indicators { justify-content: start; }
  .task-schedule .schedule-reason { text-align: left; }
  .mobile-tabs { display: grid; gap: 0.4rem; margin-bottom: 0.7rem; grid-template-columns: 1fr 1fr; }
  .mobile-tabs button.active { border-color: var(--primary); color: #fff; background: var(--primary); }
  .task-layout { display: block; }
  .task-pane.mobile-hidden { display: none; }
  .chat-pane, .document-pane { min-height: 31rem; max-height: none; }
  .turn { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
  button:hover:not(:disabled) { transform: none; }
}

@media (max-width: 34rem) {
  .site-header { align-items: stretch; flex-direction: column; }
  .site-header nav { display: grid; grid-template-columns: 1fr 1fr; }
  .brand { align-self: start; }
  .account-chip { align-self: start; margin-left: 0; }
  .schedule-row, .task-card-meta { align-items: start; flex-direction: column; }
  .external-link-actions { align-items: stretch; flex-direction: column-reverse; }
  .external-link-actions > * { width: 100%; }
}
