.icon-button {
  width: var(--touch-target);
  height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 20px;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}

.icon-button > svg {
  width: 18px;
  height: 18px;
  margin: auto;
}

.view {
  min-height: 100vh;
  padding-bottom: 80px;
}

.bottom-nav {
  width: min(100%, 580px);
  height: calc(59px + env(safe-area-inset-bottom));
  position: fixed;
  z-index: 8;
  bottom: 0;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px 12px calc(4px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-top: .5px solid var(--line);
  background: rgb(15 19 19 / 96%);
  backdrop-filter: blur(18px);
}

.nav-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  background: transparent;
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
}

.nav-item.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.nav-icon {
  min-height: 20px;
  font-size: 18px;
  line-height: 1;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  border-bottom: .5px solid var(--line);
}

.page-heading h1 {
  margin: 0;
  font-size: var(--text-md);
  line-height: 52px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
}

.page-heading p {
  max-width: 270px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

.section {
  padding: 24px 22px;
  border-top: .5px solid var(--line);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.field {
  min-width: 0;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  display: block;
  color: #bac3bf;
  font: var(--weight-medium) var(--text-xs)/1.4 var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.field label {
  margin-bottom: 7px;
}

.text-input,
.text-area,
.select-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  caret-color: var(--accent);
  caret-shape: bar;
  color: var(--ink);
  background: var(--surface-raised);
  line-height: 1.5;
  font-size: 16px;
  transition: border-color .18s, background .18s;
}

.select-input {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.select-control {
  width: 100%;
  min-width: 0;
  position: relative;
  scroll-margin-block: 12px;
}

.select-trigger {
  width: 100%;
  height: 48px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  text-align: left;
  transition: border-color .18s, background .18s;
}

.select-value {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-chevron {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform .18s;
}

.select-control.open .select-chevron {
  transform: translateY(2px) rotate(225deg);
}

.select-trigger:disabled {
  cursor: not-allowed;
  color: var(--faint);
  opacity: .6;
}

.select-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.select-menu {
  inset: auto;
  margin: 0;
  position: fixed;
  z-index: 1000;
  display: grid;
  gap: 2px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: 0 12px 32px rgb(0 0 0 / 34%);
  scrollbar-width: none;
  animation: select-open .08s ease-out;
}

.select-menu::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.select-menu[hidden] {
  display: none;
}

.select-option {
  width: 100%;
  min-height: var(--touch-target);
  padding: 8px 10px;
  overflow: hidden;
  color: var(--ink);
  border-radius: 5px;
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-option[aria-selected="true"] {
  color: var(--accent);
  background: var(--surface-soft);
}

.select-option:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.select-option:disabled {
  cursor: not-allowed;
  color: var(--faint);
}

@keyframes select-open {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.text-input {
  height: 48px;
  padding: 0 12px;
}

.text-area,
.markdown-body pre {
  scrollbar-width: none;
}

.text-area {
  min-height: 112px;
  padding: 11px 12px;
  resize: vertical;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.textarea-resize-shell {
  position: relative;
}

.textarea-resize-shell .character-prompt {
  display: block;
  width: 100%;
  resize: none;
}

.textarea-resize-handle {
  position: absolute;
  right: 0;
  bottom: -7px;
  left: 0;
  height: 14px;
  cursor: ns-resize;
  touch-action: none;
}

body.is-resizing-textarea {
  cursor: ns-resize;
  user-select: none;
}

.text-area::-webkit-scrollbar,
.markdown-body pre::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.text-area::-webkit-scrollbar-track,
.markdown-body pre::-webkit-scrollbar-track {
  background: transparent;
}

.text-area::-webkit-scrollbar-thumb,
.markdown-body pre::-webkit-scrollbar-thumb {
  background: rgb(141 152 147 / 30%);
  border-radius: 999px;
}

.text-area:focus::-webkit-scrollbar-thumb,
.markdown-body pre:hover::-webkit-scrollbar-thumb {
  background: rgb(141 152 147 / 58%);
}

.text-input::placeholder,
.text-area::placeholder {
  color: #65706b;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--line);
  background: var(--surface-raised);
}

.text-input:focus-visible,
.text-area:focus-visible {
  outline: none;
}

.text-input[aria-invalid="true"],
.text-area[aria-invalid="true"] {
  border-color: var(--danger-border);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.primary-button {
  color: var(--accent-ink);
  background: var(--accent);
}

.primary-button:disabled {
  color: #6f7950;
  background: #343b27;
}

.secondary-button {
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
}

.danger-button {
  color: var(--danger);
  border: 1px solid var(--danger-border);
  background: transparent;
}

.secondary-button:disabled,
.danger-button:disabled,
.admin-create-button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.compact-button {
  min-height: 42px;
  padding-inline: 13px;
  font-size: var(--text-sm);
}

.admin-action-button {
  min-width: 112px;
  min-height: 46px;
  padding-inline: 16px;
}

.dialog-actions-split {
  justify-content: space-between;
}

.dialog-action-group {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.full-width {
  width: 100%;
}

.toast {
  max-width: calc(100vw - 32px);
  position: fixed;
  z-index: 1000;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  margin: 0;
  padding: 11px 15px;
  transform: translateX(-50%);
  border: 0;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  font-weight: 700;
}

@media (hover: none) and (pointer: coarse) {
  .icon-button:active,
  .nav-item:active,
  .select-trigger:active:not(:disabled),
  .select-option:active:not(:disabled) {
    background: var(--surface-soft);
  }

  .nav-item.active:active {
    background: var(--accent-strong);
  }

  .primary-button:active:not(:disabled) {
    background: var(--accent-strong);
  }

  .auth-switch:active:not(:disabled) {
    color: var(--ink);
    background: var(--surface-soft);
  }

  .secondary-button:active:not(:disabled) {
    background: #293130;
  }

  .danger-button:active:not(:disabled) {
    background: rgb(255 129 121 / 10%);
  }
}
