/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  user-select: none;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.btn:disabled {
  opacity: 0.5;
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  gap: 6px;
  border-radius: var(--r-sm);
}
.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: var(--r-lg);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-hairline);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--raised);
}
.btn-ghost {
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--hover);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}
.btn-text-danger {
  color: var(--danger);
}
.btn-text-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ── Icon buttons with tooltip ───────────────────────────── */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  color: var(--ink-2);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled),
.icon-btn.is-active {
  background: var(--hover);
  color: var(--ink);
}
.icon-btn:disabled {
  opacity: 0.4;
}
.icon-btn.sm {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
}
.icon-btn.is-accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.icon-btn.is-recording {
  background: var(--danger-soft);
  color: var(--danger);
  animation: mg-ring 1.4s ease-out infinite;
}
.icon-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--canvas);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.icon-btn[data-tip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 6px);
}
.icon-btn[data-tip-pos="right"]::after {
  bottom: auto;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
}
@media (hover: hover) {
  .icon-btn[data-tip]:hover::after {
    opacity: 1;
    transition-delay: 0.35s;
  }
}
.icon-btn[data-tip]:focus-visible::after {
  opacity: 1;
}

/* ── Inputs ──────────────────────────────────────────────── */
.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--canvas);
  box-shadow: var(--shadow-hairline);
  font-size: 14px;
  outline: none;
}
.textarea {
  height: auto;
  padding: 8px 12px;
  resize: vertical;
  line-height: 1.5;
}
.input:focus,
.select:focus,
.textarea:focus {
  box-shadow: 0 0 0 1px var(--accent);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-3);
}
.field {
  display: grid;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.field-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-3);
}
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.checkbox input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ── Switch & segmented control ──────────────────────────── */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color 0.2s;
}
.switch::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transform: translateX(2px);
  transition: transform 0.2s var(--ease);
}
.switch[aria-checked="true"] {
  background: var(--accent);
}
.switch[aria-checked="true"]::after {
  transform: translateX(18px);
}
.switch:disabled {
  opacity: 0.5;
}
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-md);
  background: var(--canvas);
  box-shadow: var(--shadow-hairline);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.segmented button:hover {
  color: var(--ink);
}
.segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float);
}

/* ── Popover menu ────────────────────────────────────────── */
.menu {
  position: fixed;
  z-index: 90;
  padding: 4px;
  overflow-y: auto;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: mg-scale-in 0.16s var(--ease) both;
}
.menu-heading {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.menu-sep {
  height: 1px;
  margin: 4px 8px;
  background: var(--line);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  text-align: left;
  color: var(--ink);
  outline: none;
}
.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  background: var(--hover);
}
.menu-item:disabled {
  opacity: 0.4;
}
.menu-item .mi-icon {
  color: var(--ink-2);
  flex-shrink: 0;
}
.menu-item.is-danger,
.menu-item.is-danger .mi-icon {
  color: var(--danger);
}
.menu-item .mi-text {
  flex: 1;
  min-width: 0;
}
.menu-item .mi-label {
  display: block;
}
.menu-item .mi-desc {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.menu-item .mi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Dialog (bottom sheet on phones) ─────────────────────── */
.dialog-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) {
  .dialog-root {
    align-items: center;
    padding: 24px;
  }
}
.dialog-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: mg-fade-in 0.2s ease both;
}
.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(88dvh, 760px);
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding-bottom: env(safe-area-inset-bottom);
  animation: mg-scale-in 0.2s var(--ease) both;
}
@media (min-width: 640px) {
  .dialog {
    border-radius: var(--r-xl);
  }
  .dialog.w-sm {
    max-width: 420px;
  }
  .dialog.w-md {
    max-width: 560px;
  }
  .dialog.w-lg {
    max-width: 780px;
  }
}
.dialog-grip {
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: var(--line-strong);
}
@media (min-width: 640px) {
  .dialog-grip {
    display: none;
  }
}
.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px 12px;
}
.dialog-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.dialog-desc {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: 0;
}
.dialog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 20px 20px;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}
@media (min-width: 640px) {
  .dialog-header {
    padding: 20px 24px 12px;
  }
  .dialog-body {
    padding: 0 24px 24px;
  }
  .dialog-footer {
    padding: 12px 24px;
  }
}

/* ── Toasts ──────────────────────────────────────────────── */
.toasts {
  position: fixed;
  z-index: 120;
  inset: 12px 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
@media (min-width: 640px) {
  .toasts {
    inset: auto 24px 24px auto;
    align-items: flex-end;
  }
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 380px;
  padding: 10px 8px 10px 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  line-height: 1.4;
  pointer-events: auto;
  animation: mg-scale-in 0.18s var(--ease) both;
}
.toast .t-icon {
  margin-top: 1px;
  flex-shrink: 0;
  color: var(--ink-2);
}
.toast.is-error .t-icon {
  color: var(--danger);
}
.toast.is-success .t-icon {
  color: var(--accent);
}
.toast .t-text {
  flex: 1;
}
.toast .t-close {
  padding: 2px;
  border-radius: var(--r-sm);
  color: var(--ink-3);
}
.toast .t-close:hover {
  background: var(--hover);
  color: var(--ink);
}

/* ── Settings layout ─────────────────────────────────────── */
.settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 640px) {
  .settings {
    flex-direction: row;
    gap: 24px;
  }
}
.settings-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px 2px;
}
@media (min-width: 640px) {
  .settings-tabs {
    flex-direction: column;
    width: 176px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
  }
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.settings-tab svg {
  color: var(--ink-3);
}
.settings-tab:hover,
.settings-tab[aria-selected="true"] {
  background: var(--hover);
  color: var(--ink);
}
.settings-panel {
  flex: 1;
  min-width: 0;
  min-height: 340px;
}
.set-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.set-row:last-child {
  border-bottom: 0;
}
@media (min-width: 640px) {
  .set-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }
}
.set-label {
  font-size: 14px;
  font-weight: 500;
}
.set-hint {
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-3);
}
.set-row .select {
  min-width: 180px;
  max-width: 260px;
}
.card {
  padding: 14px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-hairline);
}
.stack {
  display: grid;
  gap: 14px;
}
.note {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
}
.note svg {
  flex-shrink: 0;
  margin-top: 2px;
}
.note-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.note-info {
  background: var(--accent-soft);
  color: var(--accent);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--raised);
  color: var(--ink-2);
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}
.status-pill.is-on {
  background: var(--accent-soft);
  color: var(--accent);
}
.status-pill.is-on::before {
  background: var(--accent);
}
.list {
  list-style: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-hairline);
  overflow: hidden;
}
.list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.45;
}
.list li:last-child {
  border-bottom: 0;
}
.list .grow {
  flex: 1;
  min-width: 0;
}
@media (hover: hover) {
  .list .actions {
    opacity: 0;
  }
  .list li:hover .actions,
  .list li:focus-within .actions {
    opacity: 1;
  }
}
.actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.facts {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-hairline);
  overflow: hidden;
}
.facts div {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}
.facts div:last-child {
  border-bottom: 0;
}
.facts dt {
  color: var(--ink-3);
}
.facts dd {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.about-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 20px;
}
.about-head .name {
  margin-top: 16px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.about-head .name span {
  color: var(--ink-2);
}
