:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: #fffaf0;
  --surface-strong: #ffffff;
  --ink: #17201d;
  --muted: #68706b;
  --line: #ddd5c5;
  --green: #176b5b;
  --green-dark: #0f4c41;
  --gold: #b47b22;
  --red: #a6422a;
  --blue: #276178;
  --shadow: 0 18px 50px rgba(42, 34, 19, 0.13);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.9), rgba(245, 241, 232, 0.96)),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid rgba(221, 213, 197, 0.78);
  background: rgba(255, 250, 240, 0.9);
  backdrop-filter: blur(16px);
}

.topbar > * {
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 172px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fffaf0;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.search::before {
  content: "";
  position: absolute;
  left: 15px;
  width: 13px;
  height: 13px;
  border: 2px solid var(--green);
  border-radius: 50%;
}

.search::after {
  content: "";
  position: absolute;
  left: 28px;
  width: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
  transform: rotate(45deg);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.topnav,
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a {
  padding: 10px 8px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.topnav a:hover {
  color: var(--ink);
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border-color: var(--green);
  background: var(--green);
  color: white;
  font-weight: 700;
}

.short-label {
  display: none;
}

.primary-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  min-height: 42px;
  padding: 0 14px;
}

.icon-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--gold);
}

.icon-button::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}

.workspace {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
  padding: 22px clamp(16px, 3vw, 36px) 36px;
}

.sidebar,
.feed-panel,
.detail-panel {
  min-width: 0;
}

.sidebar,
.detail-panel {
  position: sticky;
  top: 88px;
}

.section-title,
.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topic-pill {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.topic-pill:hover,
.topic-pill.active {
  border-color: var(--line);
  background: var(--surface-strong);
}

.topic-pill strong {
  color: var(--muted);
  font-size: 12px;
}

.mini-panel,
.checklist,
.visual-card,
.question-detail,
.ask-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.mini-panel {
  margin-top: 22px;
  padding: 14px;
}

.market-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

meter {
  width: 100%;
  height: 8px;
}

.feed-panel {
  display: grid;
  gap: 14px;
}

.feed-header {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  padding: 4px 0 2px;
}

.feed-header h1 {
  max-width: 740px;
  margin: 0;
  font-size: clamp(28px, 3.2vw, 46px);
  line-height: 1.03;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.segmented button.active {
  background: var(--green);
  color: white;
}

.ask-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: #e1eee8;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.avatar-main {
  background: var(--green);
  color: #ffffff;
}

.ask-input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f0;
  color: var(--muted);
  text-align: left;
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 10px 32px rgba(42, 34, 19, 0.08);
}

.question-card.is-selected {
  border-color: rgba(23, 107, 91, 0.65);
  box-shadow: 0 14px 40px rgba(23, 107, 91, 0.16);
}

.vote-box {
  display: grid;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.vote-box span {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.vote-box strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
}

.question-main h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.question-main h2 button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.question-main h2 button:hover {
  color: var(--green);
}

.question-main p {
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 6px;
  background: #ecf3ef;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.meta-row {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.status {
  color: var(--blue);
  font-weight: 800;
}

.status.active {
  color: var(--green);
}

.status.closed {
  color: var(--red);
}

.detail-panel {
  display: grid;
  gap: 14px;
}

.question-detail {
  padding: 18px;
}

.question-detail h2 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.2;
}

.question-detail p {
  color: var(--muted);
  line-height: 1.55;
}

.answer {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f0;
}

.answer.is-featured {
  border-color: rgba(23, 107, 91, 0.45);
}

.answer-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 800;
}

.answer-head span:last-child {
  display: grid;
  gap: 2px;
}

.answer-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.answer p {
  margin: 0 0 8px;
}

.answer p:last-child {
  margin-bottom: 0;
}

.thread-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.thread-toolbar span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.reply-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.reply-gallery.is-multi {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reply-photo {
  display: block;
  overflow: hidden;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e5dfd0;
}

.reply-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 160ms ease;
}

.reply-photo:hover img {
  transform: scale(1.04);
}

.reply-composer {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed rgba(23, 107, 91, 0.45);
  border-radius: 8px;
  background: #f8f5ed;
}

.composer-input {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  line-height: 1.35;
}

.composer-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.visual-card {
  overflow: hidden;
}

.visual-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  background: #e5dfd0;
}

.visual-card div {
  padding: 15px;
}

.visual-card h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.24;
}

.checklist {
  display: grid;
  gap: 10px;
  padding: 15px;
}

.checklist label {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--muted);
  line-height: 1.35;
}

.login-dialog {
  width: min(420px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
}

.login-dialog::backdrop {
  background: rgba(23, 32, 29, 0.42);
  backdrop-filter: blur(2px);
}

.login-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--surface-strong);
}

.login-card h2,
.login-card p {
  margin: 0;
}

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

.login-card label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.login-card input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.wide {
  width: 100%;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 2;
    position: static;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .search {
    grid-column: 1 / -1;
    order: 3;
  }

  .topnav {
    display: none;
  }

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

  .sidebar,
  .detail-panel {
    position: static;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sidebar .section-title,
  .mini-panel {
    grid-column: 1 / -1;
  }

  .topic-pill {
    margin-bottom: 0;
  }

  .detail-panel {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: 390px;
    max-width: 100vw;
    overflow: hidden;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px 24px 12px 12px;
  }

  .brand {
    min-width: 0;
  }

  .top-actions {
    justify-self: end;
  }

  .search {
    grid-column: 1 / -1;
    order: 3;
    width: 100%;
  }

  .brand small,
  .ghost-button,
  .icon-button {
    display: none;
  }

  .primary-button {
    min-width: 76px;
    padding: 0 11px;
  }

  .wide-label {
    display: none;
  }

  .short-label {
    display: inline;
  }

  .workspace {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    padding: 16px 24px 28px 12px;
  }

  .feed-panel,
  .question-list,
  .detail-panel,
  .sidebar {
    width: 100%;
    max-width: calc(100vw - 36px);
    overflow: hidden;
  }

  .feed-header {
    display: grid;
  }

  .feed-header h1 {
    font-size: 30px;
    max-width: calc(100vw - 36px);
    word-break: break-word;
  }

  .segmented {
    width: 100%;
    max-width: calc(100vw - 36px);
  }

  .segmented button {
    flex: 1;
    min-width: 0;
    padding: 0 8px;
  }

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

  .question-card {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: calc(100vw - 36px);
  }

  .question-main,
  .question-main h2 button {
    min-width: 0;
    max-width: 100%;
  }

  .vote-box {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
    min-height: 48px;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }
}
