/* Base visual compartida */
:root {
  color-scheme: dark;
  --paper: #0c0d0f;
  --paper-light: #151618;
  --ink: #f2f0e9;
  --muted: #aaa7a0;
  --line: #3b3c3f;
  --blue: #365bdc;
  --blue-text: #6f8fff;
  --blue-dark: #183ba0;
  --red: #dd5b48;
  --yellow: #f1d14d;
  --white: #ffffff;
  --danger: #b42f2f;
  --max-width: 1180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--paper);
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

h1,
h2,
p,
dl,
dd {
  margin-top: 0;
}

/* Marca y navegación */
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-brand-mark {
  width: 27px;
  height: 27px;
  position: relative;
  display: inline-block;
  background: var(--red);
  border-radius: 4px;
}

.app-brand-mark::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 7px;
  width: 11px;
  height: 6px;
  border-bottom: 3px solid var(--white);
  border-left: 3px solid var(--white);
  transform: rotate(-45deg);
}

.quiet-link,
.quiet-button,
.project-return {
  padding-bottom: 4px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.quiet-button {
  padding: 0 0 4px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.quiet-link:hover,
.quiet-button:hover,
.project-return:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.eyebrow {
  margin-bottom: 13px;
  color: var(--blue-text);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Pantalla de acceso */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.login-header,
.app-header,
.app-footer {
  width: min(var(--max-width), calc(100% - 48px));
  margin-inline: auto;
}

.login-header,
.app-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.login-shell {
  width: min(1000px, calc(100% - 48px));
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.7fr);
  align-self: center;
  margin: 50px auto;
  border: 1px solid var(--ink);
  background: #131416;
  box-shadow: 18px 18px 0 var(--blue);
}

.login-panel,
.demo-access {
  padding: 54px;
}

.login-panel h1 {
  margin-bottom: 14px;
  font-size: 3rem;
  line-height: 0.96;
}

.login-intro {
  margin-bottom: 28px;
  color: var(--muted);
}

.demo-access {
  color: var(--white);
  background: var(--blue);
}

.demo-access .eyebrow {
  color: var(--white);
}

.demo-access dl {
  margin: 36px 0 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.45);
}

.demo-access dl div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
}

.demo-access dt,
.demo-access dd {
  font-size: 0.82rem;
}

.demo-access dd {
  margin-bottom: 0;
  font-weight: 700;
}

.demo-access > p:last-child {
  color: #dfe5ff;
  font-size: 0.82rem;
}

.form-error {
  padding: 10px 12px;
  color: #7e1919;
  background: #ffe1dc;
  border-left: 4px solid var(--danger);
  font-size: 0.84rem;
}

.active-session p {
  color: var(--muted);
}

/* Formularios */
.login-form,
.task-form {
  display: grid;
  gap: 18px;
}

.field-group {
  display: grid;
  gap: 7px;
}

.field-group label {
  font-size: 0.78rem;
  font-weight: 700;
}

.field-group input,
.field-group textarea {
  width: 100%;
  padding: 12px 13px;
  background: #101113;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
}

.field-group input {
  min-height: 46px;
}

.field-group textarea {
  min-height: 150px;
  resize: vertical;
}

.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--blue-text);
  box-shadow: 0 0 0 3px rgba(40, 86, 219, 0.12);
}

.primary-action {
  width: fit-content;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  color: var(--white);
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
}

.primary-action:hover {
  background: var(--blue-dark);
}

.primary-action:disabled,
.delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.form-status {
  min-height: 1.35em;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.form-status.is-success {
  color: #b9f451;
}

.form-status.is-error {
  color: #ff9c8d;
}

/* Cabecera y estructura de la aplicación */
.app-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(12, 13, 15, 0.94);
  backdrop-filter: blur(12px);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logout-form {
  margin: 0;
}

.user-actions > span {
  font-size: 0.82rem;
  font-weight: 700;
}

.app-main {
  width: min(var(--max-width), calc(100% - 48px));
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr);
  align-items: start;
  margin: 46px auto 70px;
  border-top: 1px solid var(--ink);
}

.composer,
.tasks-panel {
  padding-top: 34px;
}

.composer {
  position: sticky;
  top: 100px;
  padding-right: 48px;
}

.composer h1 {
  margin-bottom: 16px;
  font-size: 2.5rem;
  line-height: 1;
}

.section-intro {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tasks-panel {
  min-height: 560px;
  padding-left: 48px;
  border-left: 1px solid var(--line);
}

.tasks-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.tasks-heading h2 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1;
}

/* Lista de tareas */
.task-list-form {
  display: grid;
  gap: 18px;
}

.task-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-card {
  overflow: hidden;
  background: #151618;
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 160ms ease, transform 160ms ease;
}

.task-card:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.task-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 14px;
  padding: 17px;
  cursor: pointer;
}

.task-item input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--blue);
}

.task-text {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.task-text strong {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.task-text > span {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.task-text small {
  color: #908d87;
  font-size: 0.68rem;
}

.empty-state {
  padding: 42px 24px;
  color: var(--muted);
  background: #1b1c1f;
  border: 1px dashed #656660;
  text-align: center;
  font-size: 0.88rem;
}

.delete-button {
  width: fit-content;
  min-height: 40px;
  padding: 0 14px;
  color: var(--danger);
  background: transparent;
  border: 1px solid #d7a39e;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.delete-button:hover {
  color: var(--white);
  background: var(--danger);
  border-color: var(--danger);
}

/* Pie de la aplicación */
.app-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
}

.app-footer p {
  margin-bottom: 0;
}

.app-footer a {
  color: var(--ink);
}

/* Estados usados por las peticiones asíncronas */
.fade-in {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 300ms ease, transform 300ms ease;
}

.fade-in.show {
  opacity: 1;
  transform: translateY(0);
}

.fade-out {
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 300ms ease, transform 300ms ease;
}

/* Adaptación para móvil */
@media (max-width: 760px) {
  .login-header,
  .app-header,
  .app-footer,
  .app-main {
    width: min(100% - 28px, var(--max-width));
  }

  .login-shell {
    width: min(100% - 28px, 620px);
    grid-template-columns: 1fr;
    margin: 34px auto 48px;
    box-shadow: 10px 10px 0 var(--blue);
  }

  .login-panel,
  .demo-access {
    padding: 34px 26px;
  }

  .login-panel h1 {
    font-size: 2.35rem;
  }

  .app-main {
    grid-template-columns: 1fr;
    margin-top: 30px;
  }

  .composer {
    position: static;
    padding: 28px 0 44px;
    border-bottom: 1px solid var(--ink);
  }

  .tasks-panel {
    min-height: 0;
    padding: 42px 0 0;
    border-left: 0;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 18px 0;
  }
}

@media (max-width: 430px) {
  .login-header,
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
    padding: 14px 0;
  }

  .user-actions {
    width: 100%;
    justify-content: space-between;
  }

  .composer h1 {
    font-size: 2.1rem;
  }

  .tasks-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .task-card,
  .fade-in,
  .fade-out {
    transition: none;
  }
}
