:root {
  color-scheme: dark;
  --bg: #101316;
  --panel: #171b1f;
  --panel-2: #20262b;
  --panel-3: #2a3035;
  --text: #f5f1e8;
  --muted: #a5a099;
  --faint: #74706a;
  --line: rgba(245, 241, 232, 0.12);
  --accent: #b78cff;
  --accent-2: #7be0c3;
  --danger: #ff8f8f;
  --warn: #f6c76e;
  --ok: #8ee59f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  --radius: 18px;
  --tap: 48px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 24% 0%, rgba(183, 140, 255, 0.28), transparent 28rem),
    radial-gradient(circle at 92% 20%, rgba(123, 224, 195, 0.16), transparent 24rem),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

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

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.phone {
  width: min(100vw, 430px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18rem),
    var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  .app-shell {
    align-items: center;
    padding: 28px 0;
  }

  .phone {
    min-height: min(900px, calc(100vh - 56px));
    height: min(900px, calc(100vh - 56px));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 34px;
  }
}

.topbar {
  flex: 0 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 19, 22, 0.88);
  backdrop-filter: blur(22px);
  z-index: 5;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #5d7cff);
  color: white;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.topbar-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn,
.pill-btn,
.primary-btn,
.quiet-btn,
.danger-btn {
  border: 0;
  cursor: pointer;
  min-height: 40px;
  border-radius: 999px;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.icon-btn:active,
.pill-btn:active,
.primary-btn:active,
.quiet-btn:active,
.danger-btn:active,
.tab-btn:active,
.card:active {
  transform: scale(0.98);
}

.icon-btn {
  width: 40px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.primary-btn,
.pill-btn,
.quiet-btn,
.danger-btn {
  padding: 0 15px;
  font-weight: 700;
}

.primary-btn {
  background: var(--accent);
  color: #170f24;
}

.pill-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.pill-btn.active {
  background: rgba(183, 140, 255, 0.18);
  border-color: rgba(183, 140, 255, 0.54);
  color: #e6d7ff;
}

.quiet-btn {
  background: transparent;
  border: 1px solid var(--line);
}

.danger-btn {
  background: rgba(255, 143, 143, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 143, 143, 0.26);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 104px;
  scrollbar-width: none;
}

.content::-webkit-scrollbar {
  display: none;
}

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

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.06em;
  line-height: 0.96;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.search:focus,
.field:focus,
.note-field:focus {
  border-color: rgba(183, 140, 255, 0.64);
  box-shadow: 0 0 0 3px rgba(183, 140, 255, 0.15);
}

.chip-row,
.action-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar,
.action-row::-webkit-scrollbar {
  display: none;
}

.card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
  padding: 15px;
  color: var(--text);
  cursor: pointer;
}

.card h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  color: var(--faint);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(123, 224, 195, 0.12);
  color: #b7f8e9;
  font-weight: 700;
  font-size: 11px;
}

.badge.warn {
  background: rgba(246, 199, 110, 0.13);
  color: var(--warn);
}

.field,
.note-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  padding: 14px;
  resize: vertical;
}

.field {
  min-height: 190px;
}

.note-field {
  min-height: 320px;
  line-height: 1.52;
}

.output {
  border: 1px solid rgba(123, 224, 195, 0.22);
  border-radius: 20px;
  padding: 15px;
  background: rgba(123, 224, 195, 0.08);
}

.output h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #b7f8e9;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.output p {
  margin: 0;
  color: #e8fff8;
  line-height: 1.5;
  white-space: pre-wrap;
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 3px;
  background: var(--accent-2);
  vertical-align: text-bottom;
  animation: blink 0.9s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(var(--tab-count), minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid var(--line);
  background: rgba(16, 19, 22, 0.92);
  backdrop-filter: blur(22px);
  z-index: 8;
}

.tab-btn {
  min-height: 58px;
  border: 1px solid transparent;
  border-radius: 17px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
}

.tab-btn span:first-child {
  font-size: 20px;
  line-height: 1;
}

.tab-btn.active {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 20;
  display: flex;
  align-items: flex-end;
}

.sheet {
  width: 100%;
  max-height: 88%;
  overflow-y: auto;
  background: #15191d;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  box-shadow: 0 -20px 70px rgba(0, 0, 0, 0.34);
}

.sheet h2 {
  margin: 0;
  font-size: 20px;
}

.sheet p {
  color: var(--muted);
  font-size: 13px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px;
  background: var(--panel);
}

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

.row-title strong {
  display: block;
}

.row-title small {
  display: block;
  color: var(--muted);
}

.move-controls {
  display: flex;
  gap: 6px;
}

.move-controls button {
  min-width: 36px;
  min-height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.toast {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 90px;
  padding: 12px 14px;
  background: rgba(245, 241, 232, 0.94);
  color: #15191d;
  border-radius: 16px;
  font-weight: 800;
  z-index: 30;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

.canvas-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
}

.voice-orb {
  width: 136px;
  height: 136px;
  margin: 22px auto;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, rgba(183, 140, 255, 0.35), rgba(183, 140, 255, 0.08) 62%, transparent 63%),
    var(--panel-2);
  border: 1px solid rgba(183, 140, 255, 0.3);
}

.voice-orb.listening {
  animation: pulse 1.25s ease-in-out infinite;
}

@keyframes pulse {
  50% { transform: scale(1.04); box-shadow: 0 0 0 18px rgba(183, 140, 255, 0.06); }
}

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

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 360px) {
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .section-head h2 {
    font-size: 24px;
  }
}
