*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.icon { flex: none; display: block; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s var(--ease), border-color .14s var(--ease), transform .06s var(--ease);
}
.btn:hover  { background: var(--bg-hover); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-sm); }
.btn.block { width: 100%; }

/* Icon-only buttons — used for every destructive action. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.icon-btn.ghost { border-color: transparent; }
.icon-btn.bordered { border-color: var(--border); background: var(--bg-elevated); }
.icon-btn.bordered:hover { border-color: var(--border-strong); }
.icon-btn.danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.small { width: 26px; height: 26px; }

/* -------------------------------------------------------------- inputs */

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--border-strong); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input:disabled { opacity: .55; cursor: not-allowed; }

.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.55; }

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa7b8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  cursor: pointer;
}

.input-secret { font-family: var(--mono); letter-spacing: .02em; }

.input-row { position: relative; display: flex; align-items: center; }
.input-row .input { padding-right: 76px; }
.input-row .input-actions {
  position: absolute;
  right: 3px;
  display: flex;
  gap: 1px;
}

/* --------------------------------------------------------------- field */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.field-label .req { color: var(--danger); }
.field-hint { font-size: 12px; color: var(--text-faint); line-height: 1.45; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}
.field-grid .field.wide,
.field-grid > .wide { grid-column: 1 / -1; }
/* A button dropped into a full-width cell should hug its label, not stretch. */
.field.wide > .btn:only-of-type { align-self: flex-start; }

@media (max-width: 620px) {
  .field-grid { grid-template-columns: 1fr; }
}
