* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --background: #fdfbd4;
  --surface: #f7f6cf;
  --surface-lowest: #ffffff;
  --surface-container: #f2f0c9;
  --surface-high: #eceac4;
  --surface-variant: #e6e4bf;
  --primary: #336318;
  --primary-container: #4b7c2f;
  --primary-fixed: #baf296;
  --secondary-container: #b6f082;
  --tertiary: #834900;
  --tertiary-fixed: #ffb875;
  --text: #1c1d06;
  --muted: #72796b;
  --line: #c2c9b8;
  --line-soft: rgba(75, 124, 47, .12);
}

html,
body {
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 75% 0%, rgba(186, 242, 150, .38), transparent 30rem),
    linear-gradient(180deg, #fdfbd4 0%, #f7f6cf 100%);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0;
  margin: 0;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease, transform .18s ease;
}

button:active {
  transform: scale(.98);
}

select,
input,
textarea {
  color: var(--text);
}

select option {
  background: var(--surface-lowest);
  color: var(--text);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
}

::selection {
  background: rgba(182, 240, 130, .7);
}

.material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
}

.sidebar-transition {
  transition: width .28s ease, transform .28s ease;
}

.brand-mark,
.brand-orb {
  align-items: center;
  background: var(--primary-container);
  border-radius: 999px;
  color: #deffc5;
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 800;
  height: 2.5rem;
  justify-content: center;
  width: 2.5rem;
}

.brand-orb {
  background: linear-gradient(135deg, var(--primary-fixed), var(--secondary-container));
  color: #082100;
  height: 4rem;
  width: 4rem;
}

.brand-orb .material-symbols-outlined {
  font-size: 2rem;
  font-variation-settings: 'FILL' 1;
}

.brand-orb.small {
  height: 3rem;
  width: 3rem;
}

.brand-orb.small .material-symbols-outlined {
  font-size: 1.5rem;
}

.icon-btn,
.mini-icon {
  align-items: center;
  border-radius: .5rem;
  color: var(--primary-container);
  display: inline-flex;
  height: 2.4rem;
  justify-content: center;
  width: 2.4rem;
}

.icon-btn:hover {
  background: var(--surface-bright, #fffde5);
}

.tab-btn,
.secondary-action {
  align-items: center;
  border: 1px solid transparent;
  border-radius: .5rem;
  color: rgba(75, 124, 47, .75);
  display: flex;
  gap: .75rem;
  min-height: 3rem;
  padding: .75rem 1rem;
  text-align: left;
  width: 100%;
}

.tab-btn:hover,
.secondary-action:hover {
  background: rgba(255, 255, 255, .54);
  color: var(--primary-container);
  transform: translateX(4px);
}

.tab-active {
  background: var(--secondary-container) !important;
  color: var(--primary-container) !important;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(75, 124, 47, .09);
}

.tab-symbol {
  font-variation-settings: 'FILL' 1;
}

.label-caps {
  color: var(--muted);
  display: inline-block;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.view-shell {
  margin-inline: auto;
  max-width: 1280px;
  min-height: 100vh;
  padding: 2.5rem 1.5rem;
  width: 100%;
}

.page-title {
  color: var(--text);
  font-size: clamp(2.2rem, 4vw, 4rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.page-subtitle,
.section-copy {
  color: var(--muted);
  font-size: 1rem;
}

.section-title {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
}

.body-label {
  color: var(--muted);
  display: block;
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .5rem;
}

.app-surface,
.control-card,
.chat-panel,
.processing-card {
  background: var(--surface-lowest);
  border: 1px solid var(--line-soft);
  box-shadow: 0 18px 60px rgba(75, 124, 47, .07);
}

.control-card {
  border-radius: .75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
}

.feature-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(300px, 384px) minmax(0, 1fr);
}

.result-area {
  min-width: 0;
}

.section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.field {
  background: var(--surface-container) !important;
  border: 1px solid rgba(51, 99, 24, .2) !important;
  border-radius: .5rem !important;
  color: var(--text) !important;
}

.field::placeholder {
  color: rgba(66, 73, 60, .58);
}

.field:focus,
.field:focus-within {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary);
}

.composer {
  background: var(--surface-container);
  border: 1px solid rgba(51, 99, 24, .18);
  border-radius: .75rem;
}

.primary-action,
.send-btn {
  align-items: center;
  background: linear-gradient(135deg, var(--primary-fixed), var(--secondary-container));
  border-radius: .75rem;
  color: #082100;
  display: inline-flex;
  gap: .6rem;
  justify-content: center;
}

.primary-action:hover,
.send-btn:hover {
  opacity: .9;
}

.send-btn {
  flex: 0 0 auto;
  height: 2.65rem;
  width: 2.65rem;
}

.secondary-action {
  background: var(--tertiary-fixed);
  color: #2d1600;
  font-weight: 800;
}

.ghost-link {
  align-items: center;
  color: var(--primary);
  display: inline-flex;
  font-weight: 700;
  gap: .25rem;
}

.ghost-link:hover {
  color: var(--primary-container);
}

.pill {
  align-items: center;
  background: var(--surface);
  border: 1px solid rgba(51, 99, 24, .18);
  border-radius: .5rem;
  color: var(--muted);
  display: inline-flex;
  font-size: .92rem;
  font-weight: 700;
  gap: .4rem;
  justify-content: center;
  min-height: 2.55rem;
  padding: 0 .9rem;
  white-space: nowrap;
}

.pill:hover {
  border-color: rgba(51, 99, 24, .42);
  color: var(--primary);
}

.pill.active {
  background: var(--secondary-container);
  border-color: var(--secondary-container);
  color: #3e6f0d;
  box-shadow: 0 4px 14px rgba(75, 124, 47, .08);
}

.segmented {
  background: var(--surface-container);
  border-radius: .75rem;
  display: flex;
  gap: .35rem;
  padding: .25rem;
}

.segmented .pill {
  border-color: transparent;
  flex: 1;
}

.chat-panel {
  border-radius: .75rem;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 11.5rem);
  overflow: hidden;
}

.chat-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

.msg-fade {
  animation: fadeIn .26s ease;
}

.message-user {
  background: var(--primary-container);
  border-radius: 1rem;
  border-top-right-radius: .25rem;
  color: #fff;
}

.message-ai {
  color: var(--text);
  line-height: 1.75;
}

.message-ai code,
pre {
  background: rgba(75, 124, 47, .08) !important;
  border: 1px solid rgba(75, 124, 47, .14);
  color: var(--text);
}

.gallery-grid {
  display: grid;
  gap: 1rem;
  grid-auto-rows: 250px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gallery-card,
.video-thumb {
  background: var(--surface-lowest);
  border: 1px solid var(--line-soft);
  border-radius: .75rem;
  overflow: hidden;
  position: relative;
}

.gallery-card-large {
  grid-column: span 2;
  grid-row: span 2;
}

.organic-art {
  background:
    radial-gradient(circle at 25% 30%, rgba(186, 242, 150, .98), transparent 22%),
    radial-gradient(circle at 58% 52%, rgba(75, 124, 47, .94), transparent 26%),
    radial-gradient(circle at 72% 30%, rgba(255, 184, 117, .95), transparent 24%),
    linear-gradient(135deg, #fffde3, #f2f0c9);
}

.node-art {
  background:
    radial-gradient(circle at 30% 35%, rgba(182, 240, 130, .9) 0 9px, transparent 10px),
    radial-gradient(circle at 70% 65%, rgba(51, 99, 24, .65) 0 7px, transparent 8px),
    linear-gradient(140deg, #fff, #e6e4bf);
}

.terrarium-art {
  background:
    radial-gradient(circle at 50% 60%, rgba(75, 124, 47, .9), transparent 28%),
    conic-gradient(from 45deg at 50% 48%, rgba(255,255,255,.8), rgba(194,201,184,.35), rgba(255,255,255,.8)),
    linear-gradient(140deg, #fff, #f2f0c9);
}

.gallery-overlay {
  background: linear-gradient(0deg, rgba(0, 0, 0, .72), transparent);
  bottom: 0;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  left: 0;
  opacity: 0;
  padding: 1rem;
  position: absolute;
  right: 0;
  transition: opacity .18s ease;
}

.gallery-card:hover .gallery-overlay {
  opacity: 1;
}

.mini-icon {
  background: rgba(255,255,255,.18);
  color: #fff;
}

.mini-icon:hover {
  background: rgba(255,255,255,.32);
}

.soft-panel {
  background: var(--surface-lowest) !important;
  border: 1px solid var(--line-soft);
  border-radius: .75rem;
}

.soft-panel img,
.soft-panel video {
  border-radius: .75rem;
}

.video-preview {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(0deg, rgba(8, 33, 0, .2), rgba(8, 33, 0, .2)),
    radial-gradient(circle at 55% 30%, rgba(253, 251, 212, .8), transparent 18%),
    linear-gradient(135deg, #314827, #9fb990 55%, #263f24);
  border: 1px solid var(--line-soft);
  border-radius: 1rem;
  overflow: hidden;
  position: relative;
}

.play-orb {
  align-items: center;
  background: rgba(253, 251, 212, .9);
  border-radius: 999px;
  color: var(--primary-container);
  display: flex;
  height: 4rem;
  justify-content: center;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4rem;
}

.play-orb .material-symbols-outlined {
  font-size: 2.4rem;
  font-variation-settings: 'FILL' 1;
}

.video-bar {
  background: linear-gradient(0deg, rgba(0,0,0,.78), transparent);
  bottom: 0;
  left: 0;
  padding: 1rem;
  position: absolute;
  right: 0;
}

.progress-line,
.meter {
  background: rgba(255,255,255,.3);
  border-radius: 999px;
  height: .35rem;
  margin-bottom: .65rem;
  overflow: hidden;
}

.progress-line span,
.meter span {
  background: var(--primary-fixed);
  display: block;
  height: 100%;
  width: 35%;
}

.processing-card {
  align-items: center;
  border-radius: .75rem;
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
}

.meter {
  background: var(--surface-variant);
  margin: 0;
}

.meter span {
  background: var(--tertiary-fixed);
  width: 65%;
}

.video-thumb {
  align-items: center;
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
}

.video-thumb span:not(.material-symbols-outlined) {
  background: rgba(0,0,0,.62);
  border-radius: .35rem;
  color: #fff;
  font-size: .78rem;
  padding: .2rem .5rem;
  position: absolute;
  right: .5rem;
  top: .5rem;
}

.canyon-art {
  background:
    linear-gradient(135deg, rgba(51,99,24,.42), transparent),
    radial-gradient(circle at 50% 50%, #7bd1c2, transparent 20%),
    linear-gradient(135deg, #294126, #d6c08a);
}

.watch-art {
  background:
    repeating-conic-gradient(from 0deg, #9a6c35 0 10deg, #2d1600 10deg 20deg);
}

.add-thumb {
  background: var(--surface-variant);
  color: var(--muted);
}

.add-thumb .material-symbols-outlined {
  font-size: 2.5rem;
}

.upload-preview {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: .75rem;
  display: flex;
  gap: .85rem;
  padding: .65rem;
}

.upload-preview img {
  aspect-ratio: 1 / 1;
  border-radius: .55rem;
  height: 4.5rem;
  object-fit: cover;
  width: 4.5rem;
}

.upload-preview button {
  color: var(--primary);
  font-weight: 700;
  margin-left: auto;
  padding: .5rem .75rem;
}

pre {
  border-radius: .75rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

.loading-dots span {
  animation: pulse 1.4s infinite;
  display: inline-block;
}

.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

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

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  #sidebar {
    display: flex;
    transform: translateX(-100%);
  }

  #sidebar.sidebar-mobile-open {
    transform: translateX(0);
  }

  .view-shell {
    padding-inline: 1rem;
  }

  .page-title {
    font-size: 2.35rem;
  }

  .gallery-grid {
    grid-auto-rows: 220px;
    grid-template-columns: 1fr;
  }

  .gallery-card-large {
    grid-column: span 1;
    grid-row: span 1;
  }

  .segmented {
    flex-wrap: wrap;
  }

  .chat-panel {
    min-height: calc(100vh - 11rem);
  }
}
