:root {
  --bg: #f4ebda;
  --card: rgba(250, 246, 239, 0.9);
  --text: #14211f;
  --muted: #5d675f;
  --line: rgba(20, 33, 31, 0.12);
  --accent: #0e8a7b;
  --accent-soft: #c9f1eb;
  --danger: #b33f28;
  --shadow: 0 24px 70px rgba(20, 33, 31, 0.12);
  --radius: 22px;
  --font: "Bahnschrift", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(14, 138, 123, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(179, 63, 40, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f1e6 0%, #f1e1c8 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  position: relative;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(20, 33, 31, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(20, 33, 31, 0.03) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.6), transparent 90%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.hero {
  display: grid;
  gap: 18px;
  align-items: end;
  grid-template-columns: 1fr auto;
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(16, 34, 31, 0.96), rgba(20, 54, 50, 0.92));
  color: #f7f3eb;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: #87d8cd;
}

.hero h1 {
  margin: 0;
  line-height: 0.96;
  font-size: clamp(2rem, 5vw, 4.3rem);
}

.subtitle {
  margin: 12px 0 0;
  max-width: 56ch;
  color: rgba(247, 243, 235, 0.8);
}

.hero-badge {
  justify-self: start;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(135, 216, 205, 0.12);
  color: #b9fff5;
  border: 1px solid rgba(135, 216, 205, 0.22);
}

.card {
  margin-top: 14px;
  padding: 18px;
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  margin-bottom: 14px;
}

.card-head h2,
.card-head h3 {
  margin: 0;
}

.card-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.split {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.compact-head {
  margin-top: 14px;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.stack-form.compact textarea {
  min-height: 88px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.94rem;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 138, 123, 0.12);
}

textarea {
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.btn.primary {
  color: #effaf8;
  background: linear-gradient(135deg, #0e8a7b, #0a5c54);
}

.btn.secondary {
  color: #10221f;
  background: linear-gradient(135deg, #f4d79f, #ebbe63);
}

.btn.ghost {
  color: var(--text);
  background: rgba(20, 33, 31, 0.08);
}

.btn.mini {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.main-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.4fr) minmax(280px, 0.95fr);
}

.sidebar,
.admin-panel {
  align-self: start;
}

.list,
.session-list,
.message-list,
.device-list {
  display: grid;
  gap: 10px;
}

.project-card,
.session-card {
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(20, 33, 31, 0.1);
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  cursor: pointer;
}

.project-card.active,
.session-card.active {
  background: var(--accent-soft);
  border-color: rgba(14, 138, 123, 0.35);
}

.project-top,
.project-bottom,
.session-top,
.session-bottom,
.composer-row,
.device-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.project-meta,
.project-bottom,
.session-preview,
.session-bottom,
.device-meta,
.muted-block,
.pending-status {
  color: var(--muted);
}

.message-list {
  min-height: 320px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.message {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(20, 33, 31, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.message.assistant {
  background: rgba(14, 138, 123, 0.08);
}

.message-role {
  margin-bottom: 6px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-body {
  line-height: 1.55;
  white-space: normal;
}

.message-time {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(20, 33, 31, 0.15);
  border-radius: 18px;
  padding: 26px;
}

.composer {
  margin-top: 14px;
}

.run-status {
  display: flex;
  align-items: center;
  color: var(--muted);
}

.status-cards {
  display: grid;
  gap: 10px;
}

.tailscale-controls {
  margin-top: 10px;
}

.status-card,
.device-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(20, 33, 31, 0.08);
}

.status-card h3 {
  margin: 0 0 8px;
}

.status-card p {
  margin: 0;
  line-height: 1.5;
  color: var(--muted);
}

.device-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.82rem;
  background: rgba(20, 33, 31, 0.08);
}

.pill.pending {
  background: rgba(235, 190, 99, 0.28);
}

.pill.approved {
  background: rgba(14, 138, 123, 0.18);
}

.pill.rejected,
.pill.revoked {
  background: rgba(179, 63, 40, 0.18);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(16, 34, 31, 0.92);
  color: #f7f3eb;
  box-shadow: var(--shadow);
}

.toast.error {
  background: rgba(179, 63, 40, 0.96);
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 14px, 1400px);
    padding-top: 8px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .card,
  .hero {
    padding: 16px;
    border-radius: 24px;
  }

  .split,
  .composer-row,
  .device-head,
  .project-top,
  .project-bottom,
  .session-top,
  .session-bottom {
    flex-direction: column;
  }

  .message-list {
    max-height: 46vh;
  }
}
