/* ---- dialogs (name, new room, close room) ----------------------------- */

.dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: dialog-in 0.4s var(--ease); }
/* A dialog that takes the focus itself (ChoiceDialog) shows no ring; its buttons do, once tabbed to. */
.dialog:focus { outline: none; }

.dialog::backdrop {
  background: rgb(17 17 17 / 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
}

.dialog form {
  display: flex;
  flex-direction: column;
  padding: 28px;
}

.dialog .logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  margin-bottom: 18px;
}
.dialog .logo svg { width: 28px; height: 28px; }

.dialog h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.dialog .intro {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.field-label {
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
}

.field { position: relative; }

.field input {
  width: 100%;
  height: 46px;
  padding: 0 56px 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming in on focus */
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.2);
}
.field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.15);
}

.field .count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.dialog .error {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.dialog .rules {
  margin: 2px 0 22px;
  color: var(--muted);
  font-size: 12.5px;
}

.primary {
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}
.primary:hover { opacity: 0.9; }
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: 0.55; cursor: progress; }
.primary:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Choices (new room) and button rows (close room). */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { background: var(--hover); }
.choice:has(input:checked) {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}
.choice input { margin: 3px 0 0; accent-color: #3b82f6; }
.choice strong { display: block; font-size: 14.5px; }
.choice small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.4; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.secondary {
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.secondary:hover { background: var(--hover); }
.secondary.danger { color: var(--danger); }
.secondary:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.actions.row { flex-direction: row-reverse; }
.actions.row > * { flex: 1; }

/* The name dialog's second way in: logging in (auth.md step 5). */
.login-option {
  display: flex;
  flex-direction: column;
}
.login-option[hidden] { display: none; }
.login-option .or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12.5px;
}
.login-option .or::before,
.login-option .or::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
.login-option .secondary { color: var(--text); }
.link-button {
  align-self: center;
  margin-top: 14px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover { color: var(--text); }
.link-button:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.link-button[hidden] { display: none; }
.login-option .login-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

/* ---- brush editor and brush import / export ---------------------------- */

.dialog.brush-editor { width: min(560px, calc(100vw - 32px)); }
.brush-editor form { gap: 14px; max-height: calc(100dvh - 48px); }

.brush-preview {
  flex-shrink: 0;
  width: 100%;
  height: 110px;
  border: 1px solid var(--border);
  border-radius: 14px;
  /* A checkerboard, so erasing and low opacity show. */
  background: repeating-conic-gradient(var(--hover) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px, var(--bg);
}

.editor-name { display: grid; }
.editor-name input,
.share-text {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.editor-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 6px 18px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.editor-group { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; }
.editor-group legend { padding: 8px 0 2px; font-size: 13px; font-weight: 600; }

.editor-field {
  display: grid;
  grid-template-columns: 104px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.editor-field input[type="range"] { width: 100%; }
.editor-field.toggle { grid-template-columns: auto 1fr; }
.editor-field.toggle input { margin: 0; accent-color: #3b82f6; }
.editor-field.choice select {
  grid-column: span 2;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

/* ---- canvas size -------------------------------------------------------- */

.dialog.resize { width: min(480px, calc(100vw - 32px)); }
.resize form { gap: 12px; }
.resize .intro { margin: 0; }

.resize-picture {
  width: 100%;
  height: 170px;
  border-radius: 14px;
  background: var(--hover);
}

.size-inputs { display: flex; align-items: flex-end; gap: 10px; }
.size-inputs label { flex: 1; display: grid; }
.size-inputs > span { padding-bottom: 11px; color: var(--muted); }
.size-inputs input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.preset:hover { background: var(--hover); }

.resize-warning {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgb(220 38 38 / 0.1);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}
.resize-warning[hidden] { display: none; }
.primary.danger { background: var(--danger); color: #fff; }

.dialog.transfer { width: min(480px, calc(100vw - 32px)); }
.transfer form { gap: 10px; }
.transfer .intro { margin: 0; }
.transfer .actions { margin-top: 6px; }

.dialog .status { min-height: 18px; margin: 0; color: var(--muted); font-size: 13px; }
.dialog .status.error { color: var(--danger); }

.transfer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.transfer-heading { margin: 8px 0 0; font-size: 13px; font-weight: 600; }

.file-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
}
.file-button svg { width: 18px; height: 18px; flex-shrink: 0; }

@media (max-width: 420px) {
  .transfer-row { grid-template-columns: 1fr; }
}

.share-text {
  resize: vertical;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
