:root {
  --primary: #611443;
  --primary-dark: #4a0f33;
  --bg: #f3f5f6;
  --card: #ffffff;
  --text: #1c2a2a;
  --muted: #6b7c7c;
  --border: #d9e0e0;
  --error: #c0392b;
  --ok: #1e9e6a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.view { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px auto;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Login */
.login-card { margin-top: 10vh; }
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 { font-size: 1.3rem; margin: 10px 0 2px; }

.install-help {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 0.85rem; color: var(--muted); line-height: 1.45;
}
.install-help p { margin: 6px 0; }
.install-title { font-weight: 700; color: var(--text); font-size: 0.92rem; }
.install-help strong { color: var(--text); }
.install-note { font-style: italic; }

/* Disposición en dos columnas (responsable): formulario + historial */
.app-cols {
  display: flex; flex-wrap: wrap; gap: 16px;
  max-width: 980px; margin: 0 auto; align-items: flex-start; padding: 0 8px;
}
.app-cols > .card { margin: 16px 0; max-width: none; flex: 1 1 360px; }

.historial-list { list-style: none; padding: 0; margin: 8px 0 0; }
.historial-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.hist-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.hist-tipo { font-weight: 700; color: var(--primary); font-size: 0.82rem; }
.hist-fecha { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.hist-titulo { font-weight: 600; margin: 2px 0; font-size: 0.92rem; }
.hist-meta { color: var(--muted); font-size: 0.82rem; }
.hist-estado { display: inline-block; font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; background: #efe7ec; color: var(--primary-dark); margin-top: 4px; }
.hist-link { font-size: 0.8rem; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary); color: #fff; padding: 14px 18px;
  position: sticky; top: 0; z-index: 5;
}

h2 { margin: 4px 0 18px; font-size: 1.2rem; }

form label { display: block; font-weight: 600; margin: 14px 0 0; font-size: 0.92rem; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea { resize: vertical; }

fieldset { border: none; padding: 0; margin: 16px 0 0; }
legend { font-weight: 600; font-size: 0.92rem; padding: 0; margin-bottom: 8px; }

.req { color: var(--error); }
.row { display: flex; gap: 12px; }
.col { flex: 1; }

.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented button {
  flex: 1; min-width: 90px; padding: 12px 8px; border: 1px solid var(--border);
  background: #fff; border-radius: 10px; font-size: 0.9rem; cursor: pointer; font-weight: 600;
  color: var(--text);
}
.segmented button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
.checks input { width: auto; margin: 0; }

.share-panel {
  background: #f7f1f4; border: 1px solid #e4d3dd; border-radius: 12px;
  padding: 14px; margin-bottom: 18px;
}
.share-title { font-weight: 700; margin: 0 0 4px; }
.share-row { display: flex; gap: 8px; margin: 10px 0 6px; }
.share-row input { margin: 0; font-size: 0.85rem; background: #fff; }
.share-row .rec-btn { margin: 0; white-space: nowrap; }
.share-name-label { display: block; font-weight: 600; font-size: 0.85rem; margin: 8px 0 0; }
.share-name-label input { margin-top: 4px; background: #fff; }
#share-generate { margin-top: 10px; }
#share-rotate { color: var(--primary); display: inline-block; margin-top: 6px; }

.install-details { margin-top: 18px; font-size: 0.88rem; color: var(--muted); }
.install-details summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.install-details p { margin: 8px 0; }
.install-details strong { color: var(--text); }

.audio-rec { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rec-btn {
  border: 1px solid var(--primary); background: #fff; color: var(--primary);
  border-radius: 999px; padding: 8px 16px; font-size: 0.92rem; font-weight: 600; cursor: pointer;
}
.rec-btn.recording { background: var(--primary); color: #fff; }
#rec-preview { display: flex; align-items: center; gap: 10px; width: 100%; }
#rec-preview audio { height: 36px; max-width: 70%; }

.file-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
.file-list li { padding: 4px 0; border-bottom: 1px dashed var(--border); }

button.primary, .as-button {
  display: block; width: 100%; margin-top: 22px; padding: 14px;
  background: var(--primary); color: #fff; border: none; border-radius: 10px;
  font-size: 1.05rem; font-weight: 700; cursor: pointer; text-align: center; text-decoration: none;
}
button.primary:active, .as-button:active { background: var(--primary-dark); }
button.primary:disabled { opacity: 0.6; cursor: default; }

button.link { background: none; border: none; color: inherit; cursor: pointer; font-size: 0.95rem; text-decoration: underline; }
#app-view button.link { color: #fff; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); font-weight: 600; margin-top: 10px; }

/* Éxito */
.success-card { text-align: center; margin-top: 12vh; }
.check {
  width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff;
  font-size: 2rem; line-height: 64px; margin: 0 auto 12px;
}
#new-btn { color: var(--primary); margin-top: 16px; }

/* Overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(255, 255, 255, 0.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 20;
}
.spinner {
  width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
