:root {
  --ink: #12130f;
  --muted: #73766e;
  --paper: #f3f1e9;
  --card: #fbfaf5;
  --line: #dcd9ce;
  --lime: #d5ff59;
  --lime-deep: #b8eb28;
  --night: #191b17;
  --danger: #b44032;
  --shadow: 0 24px 70px rgba(32, 33, 27, 0.11);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(213, 255, 89, 0.28), transparent 26rem),
    linear-gradient(180deg, #f8f6ef 0, var(--paper) 58rem);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
textarea, input, select { max-width: 100%; }

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

.topbar {
  height: 74px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--night);
  color: var(--lime);
  font-weight: 820;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.device-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.54);
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
  max-width: min(390px, 45vw);
}

.device-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa;
}

.device-pill.online i {
  background: #65bc27;
  box-shadow: 0 0 0 4px rgba(101,188,39,.12);
}

.hero {
  max-width: 900px;
  margin: 80px auto 90px;
  padding: 0 24px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #83867d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 7vw, 78px);
  line-height: .98;
  letter-spacing: -.065em;
  font-weight: 790;
}

.hero > p:not(.eyebrow) {
  max-width: 600px;
  margin: 22px 0 34px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.capture-card {
  padding: 12px;
  border: 1px solid rgba(52,54,46,.14);
  border-radius: 25px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.capture-card textarea {
  width: 100%;
  min-height: 136px;
  resize: vertical;
  border: 0;
  outline: none;
  padding: 17px 18px;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.65;
}

.capture-options {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 18px 10px;
  padding: 13px 0 15px;
  border-top: 1px solid var(--line);
}

.capture-options label,
.idea-settings label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

select,
.idea-settings input {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  outline: none;
}

select:focus,
.idea-settings input:focus {
  border-color: #aeb383;
  box-shadow: 0 0 0 3px rgba(213,255,89,.18);
}

.workspace-hint {
  padding-bottom: 9px;
  color: #90938a;
  font-size: 12px;
}

textarea::placeholder { color: #aaa99f; }

.capture-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 4px 3px 18px;
}

.privacy-note {
  color: #888b82;
  font-size: 12px;
}

.primary-btn, .ghost-btn, .icon-btn {
  border: 0;
  border-radius: 13px;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

.primary-btn {
  padding: 13px 19px;
  background: var(--night);
  color: white;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(20,22,17,.16);
}

.primary-btn:hover { background: #292c24; transform: translateY(-1px); }
.primary-btn:disabled { opacity: .5; transform: none; cursor: wait; }
.ghost-btn:disabled { opacity: .45; cursor: wait; }

.ghost-btn {
  padding: 10px 13px;
  color: #54574f;
  background: transparent;
  border: 1px solid var(--line);
}

.ghost-btn:hover { background: rgba(255,255,255,.72); }

.icon-btn {
  width: 38px;
  height: 38px;
  background: transparent;
  color: #777a72;
  font-size: 18px;
}

.icon-btn:hover { background: rgba(0,0,0,.05); }

.workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 26px 100px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -.04em;
}

.idea-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.idea-card {
  min-height: 250px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(251,250,245,.82);
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 36px rgba(45,45,38,.05);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.idea-card:hover {
  transform: translateY(-3px);
  border-color: #c7c3b4;
  box-shadow: 0 18px 44px rgba(45,45,38,.09);
}

.idea-card .card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #696c63;
  font-size: 12px;
  font-weight: 700;
}

.status-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9da096;
}

.status-tag.running::before { background: #e6a836; animation: pulse 1.5s infinite; }
.status-tag.queued::before { background: #8c8f86; }
.status-tag.completed::before { background: #6bb331; }
.status-tag.failed::before { background: var(--danger); }
.status-tag.awaiting_approval::before { background: #7c5ce0; animation: pulse 1.5s infinite; }
.status-tag.rejected::before { background: #999; }

@keyframes pulse {
  50% { box-shadow: 0 0 0 6px rgba(230,168,54,.14); }
}

.idea-card time {
  color: #999b93;
  font-size: 11px;
}

.idea-card h3 {
  margin: 24px 0 12px;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -.035em;
}

.idea-card .preview {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: #8c8f87;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-foot span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-foot span:first-child {
  flex: 1;
}

.empty-state {
  text-align: center;
  padding: 74px 20px;
  color: var(--muted);
}

.empty-state h3 { color: var(--ink); margin: 22px 0 8px; }
.empty-state p { margin: 0; }

.empty-orbit {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border: 1px solid #d2cfc3;
  border-radius: 50%;
}

.empty-orbit::before {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: var(--lime);
}

.empty-orbit span {
  position: absolute;
  top: 8px;
  right: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--night);
}

.dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(840px, calc(100dvh - 32px));
  padding: 0;
  border: 1px solid #d8d4c8;
  border-radius: 24px;
  background: #f8f6ef;
  box-shadow: 0 30px 100px rgba(20,22,18,.25);
  overflow-y: auto;
}

.idea-settings {
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.38);
}

.setting-row + .setting-grid { margin-top: 13px; }

.setting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.inline-control code {
  flex: none;
  color: #8a8d83;
  font-size: 11px;
  white-space: nowrap;
}

.inline-control input { flex: 1; min-width: 80px; }

.workflow-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 15px;
}

.workflow-actions span {
  margin-left: auto;
  color: #8c8f87;
  font-size: 11px;
}

.approval-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 15px;
  padding: 15px;
  border: 1px solid rgba(124,92,224,.28);
  border-radius: 14px;
  background: rgba(124,92,224,.08);
}

.approval-panel strong { font-size: 13px; }
.approval-panel p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.approval-panel > div:last-child { display: flex; gap: 8px; flex: none; }
.danger-btn { color: var(--danger); border-color: rgba(180,64,50,.24); }

.dialog::backdrop {
  background: rgba(18,20,16,.46);
  backdrop-filter: blur(5px);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(248,246,239,.94);
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -.035em;
}

.conversation {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  max-height: 46vh;
}

.message {
  max-width: 88%;
  padding: 17px 18px;
  border-radius: 18px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--night);
  color: white;
  border-bottom-right-radius: 5px;
}

.message.assistant {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.message small {
  display: block;
  margin-top: 9px;
  opacity: .55;
  font-size: 10px;
}

.reply-form {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 16px;
  background: rgba(248,246,239,.96);
  border-top: 1px solid var(--line);
}

.reply-form textarea {
  flex: 1;
  min-height: 58px;
  max-height: 160px;
  resize: vertical;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  outline: none;
}

.reply-form textarea:focus { border-color: #aeb383; }

.pair-dialog { max-width: 510px; }
.pair-copy { padding: 28px; text-align: center; }
.pair-copy > p { color: var(--muted); line-height: 1.7; margin-top: 0; }
.pair-code { margin-top: 24px; padding: 22px; border-radius: 18px; background: var(--night); color: white; }
.pair-code span { display: block; color: var(--lime); font-size: 42px; font-weight: 800; letter-spacing: .15em; }
.pair-code small { color: #aeb1a8; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  transform: translate(-50%, 20px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--night);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.auth-card {
  width: min(500px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(251,250,245,.9);
  box-shadow: var(--shadow);
}

.auth-card.compact { max-width: 440px; }
.auth-card .brand-mark { margin-bottom: 28px; }
.auth-card h1 { margin: 0; font-size: 36px; letter-spacing: -.05em; }
.auth-lead { color: var(--muted); line-height: 1.7; }
.auth-form { display: grid; gap: 18px; margin-top: 28px; }
.auth-form label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; }
.auth-form input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  outline: none;
}
.auth-form input:focus { border-color: #aeb383; box-shadow: 0 0 0 3px rgba(213,255,89,.18); }
.auth-foot { margin: 20px 0 0; color: #999b93; font-size: 12px; }
.notice { margin-top: 18px; padding: 12px 14px; border-radius: 12px; font-size: 13px; }
.notice.error { color: #852e23; background: #f8ded9; }

@media (max-width: 840px) {
  .idea-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { margin-top: 54px; }
}

@media (max-width: 620px) {
  .topbar {
    height: 64px;
    padding:
      max(8px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      0
      max(14px, env(safe-area-inset-left));
  }
  .topbar .pair-top-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 0;
  }
  .topbar .pair-top-btn::before {
    content: "+";
    font-size: 21px;
    line-height: 1;
  }
  .brand { gap: 8px; }
  .brand-mark.small { width: 32px; height: 32px; }
  .top-actions { gap: 4px; }
  .device-pill { height: 36px; padding: 0 10px; }
  .device-pill span { display: none; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .hero {
    margin: 38px auto 58px;
    padding:
      0
      max(14px, env(safe-area-inset-right))
      0
      max(14px, env(safe-area-inset-left));
  }
  .hero h1 { font-size: clamp(39px, 12.5vw, 48px); line-height: 1.03; }
  .hero > p:not(.eyebrow) { margin: 18px 0 26px; font-size: 15px; }
  .capture-card { padding: 8px; border-radius: 20px; }
  .capture-card textarea { min-height: 120px; padding: 14px; font-size: 16px; }
  .capture-foot { align-items: stretch; flex-direction: column; padding: 4px; }
  .capture-options { align-items: stretch; flex-direction: column; }
  .capture-options { margin: 0 14px 8px; gap: 10px; }
  .capture-options label { width: 100%; }
  .workspace-hint { padding-bottom: 0; }
  .capture-foot .primary-btn { width: 100%; }
  .privacy-note { padding: 0 8px; }
  select,
  .idea-settings input,
  .reply-form textarea {
    font-size: 16px;
  }
  select,
  .idea-settings input {
    min-height: 44px;
  }
  .primary-btn,
  .ghost-btn {
    min-height: 44px;
  }
  .workspace {
    padding:
      0
      max(14px, env(safe-area-inset-right))
      calc(70px + env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }
  .section-head { align-items: center; }
  .idea-grid { grid-template-columns: 1fr; }
  .idea-card { min-height: 210px; padding: 20px; border-radius: 18px; }
  .idea-card h3 { margin-top: 20px; font-size: 21px; }
  .card-foot { align-items: flex-end; }
  .card-foot span:last-child { flex: none; }
  .auth-card { padding: 30px 24px; }
  .dialog {
    width: 100vw;
    max-width: none;
    height: calc(100vh - max(8px, env(safe-area-inset-top)));
    height: calc(100dvh - max(8px, env(safe-area-inset-top)));
    max-height: none;
    margin: max(8px, env(safe-area-inset-top)) 0 0;
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
  }
  .dialog-head {
    padding:
      18px
      max(16px, env(safe-area-inset-right))
      14px
      max(16px, env(safe-area-inset-left));
  }
  .dialog-head h2 {
    max-width: calc(100vw - 92px);
    font-size: 21px;
    overflow-wrap: anywhere;
  }
  .conversation {
    max-height: none;
    padding: 18px max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left));
  }
  .idea-settings {
    padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
  }
  .setting-grid { grid-template-columns: 1fr; }
  .inline-control {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .workflow-actions { align-items: stretch; flex-direction: column; }
  .workflow-actions button { width: 100%; }
  .workflow-actions span { margin-left: 0; }
  .approval-panel { align-items: stretch; flex-direction: column; }
  .approval-panel > div:last-child { justify-content: stretch; }
  .approval-panel > div:last-child button { flex: 1; }
  .message { max-width: 94%; padding: 15px; }
  .reply-form {
    flex-direction: column;
    padding:
      12px
      max(12px, env(safe-area-inset-right))
      calc(12px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  .reply-form textarea { min-height: 52px; }
  .reply-form .primary-btn { width: 100%; }
  .pair-copy { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .pair-code span { font-size: clamp(32px, 11vw, 42px); }
}

@media (max-width: 380px) {
  .brand > span:last-child { display: none; }
  .hero { margin-top: 30px; }
  .hero h1 { font-size: 38px; }
  .section-head h2 { font-size: 25px; }
  .inline-control {
    grid-template-columns: 1fr auto;
  }
  .inline-control code {
    grid-column: 1 / -1;
  }
  .card-foot {
    align-items: flex-start;
    flex-direction: column;
  }
  .card-foot span:last-child { align-self: flex-end; }
}
