:root{
  /* --- Cores Base (Dark Default) --- */
  --bg: #0B1220;
  --card: #0F172A;
  --muted: rgba(255,255,255,.80);
  --text: rgba(255,255,255,.92);
  --soft: rgba(255,255,255,.08);
  --soft2: rgba(255,255,255,.12);
  --border: rgba(255,255,255,.14);
  
  --primary: #38BDF8;
  --primary2: rgba(56,189,248,.16);
  --danger: #FB7185;
  --danger2: rgba(251,113,133,.14);
  --shadow: 0 18px 40px rgba(0,0,0,.35);

  --radius: 18px;
  --radius2: 22px;

  --focus: 2px solid rgba(56,189,248,.9);

  /* Gradiente do Body (Dark) */
  --bg-grad: 
    radial-gradient(900px 700px at 25% 10%, rgba(15,23,42,.55), transparent 60%),
    radial-gradient(900px 700px at 80% 30%, rgba(2,6,23,.65), transparent 55%);

  /* Card (Dark - Gradiente sutil) */
  --card-bg: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  --card-border: rgba(255,255,255,.10);

  /* Texto de Detalhe */
  --text-detail: #ffffff;
  --text-detail-label: rgba(255,255,255,.78);
}

/* ===== Tema Claro (Overrides) ===== */
:root[data-theme="light"]{
  --bg: #F8FAFC;
  --card: #FFFFFF;

  --text: rgba(15, 23, 42, .92);
  --muted: rgba(51, 65, 85, .82);

  --soft: rgba(15, 23, 42, .06);
  --soft2: rgba(15, 23, 42, .10);
  --border: rgba(15, 23, 42, .14);

  --primary: #0284C7;                
  --primary2: rgba(2, 132, 199, .14);

  --danger: #E11D48;
  --danger2: rgba(225, 29, 72, .12);

  --shadow: 0 18px 40px rgba(2, 6, 23, .10);

  /* Gradiente do Body (Light) */
  --bg-grad:
    radial-gradient(900px 700px at 25% 10%, rgba(56,189,248,.18), transparent 60%),
    radial-gradient(900px 700px at 80% 30%, rgba(251,113,133,.14), transparent 55%);

  /* Card (Light - Sólido) */
  --card-bg: #FFFFFF;
  --card-border: rgba(15, 23, 42, .14);

  --text-detail: rgba(15, 23, 42, .92);
  --text-detail-label: rgba(51, 65, 85, .82);
}


*{ box-sizing:border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  /* CORREÇÃO DE VIEWPORT MOBILE: Usar min-height 100dvh e remover background daqui */
  min-height: 100dvh;
  position: relative;
  transition: color 0.3s ease;
}

/* CORREÇÃO DE BACKGROUND: Pseudo-elemento fixo evita 'pulos' no scroll mobile */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-grad), var(--bg);
  background-size: cover;
  transition: background 0.3s ease;
}

.skip-link{
  position:absolute;
  left:-999px;
  top:10px;
  background:#fff;
  color:#000;
  padding:10px 12px;
  border-radius:12px;
  z-index:999;
}
.skip-link:focus{ left:10px; outline: var(--focus); }

.app{
  /* Garante que o app ocupe a altura toda disponível */
  min-height: 100dvh; 
  display:flex;
  flex-direction:column;
  padding-bottom: 76px; /* Espaço para nav inferior */
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px); /* Suporte Safari */
  border-bottom: 1px solid var(--soft2);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
}
.brand-dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background: linear-gradient(135deg, var(--primary), #A78BFA);
  box-shadow: 0 0 0 6px var(--soft);
}
.brand-name{
  font-weight:700;
  letter-spacing:.2px;
}

.main{
  width:100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  flex:1;
  display:flex;
  /* CORREÇÃO CRÍTICA DE LAYOUT */
  flex-direction: column; /* Garante empilhamento vertical correto */
  align-items: stretch;   /* Garante que o card ocupe a largura (respeitando padding) */
  justify-content: flex-start; /* Evita centralização vertical estranha se o conteúdo for longo */
}

.screen{
  width:100%;
  animation: fadeIn 0.3s ease-out; /* Opcional: suavidade ao trocar tela */
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card{
  width:100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.title{
  margin: 4px 0 8px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing:-.3px;
  color: var(--text);
}
.subtitle{
  margin:0 0 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}
.body{
  margin: 10px 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
.help{
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.help.subtle, .safety.subtle{
  opacity:.85;
}
.h2{
  margin: 10px 0 8px;
  font-size: 16px;
  letter-spacing:-.1px;
  color: var(--text);
}

.divider{
  height:1px;
  margin: 14px 0;
  background: var(--border);
}

.actions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  margin-top: 14px;
}

.primary-btn, .secondary-btn, .danger-btn, .ghost-btn, .link-btn, .nav-btn, .pause-card{
  border-radius: 16px;
  border: 1px solid transparent;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  cursor:pointer;
  background: var(--soft);
  transition: background 0.2s, transform 0.1s;
}

.primary-btn{
  background: linear-gradient(135deg, rgba(56,189,248,.95), rgba(99,102,241,.75));
  border-color: rgba(255,255,255,.10);
  color: #041018;
}
:root[data-theme="light"] .primary-btn{
  color: #fff;
}

.primary-btn:disabled{
  opacity:.55;
  cursor:not-allowed;
  filter: grayscale(.2);
}

.secondary-btn{
  background: var(--soft);
  border-color: var(--border);
}

.danger-btn{
  background: var(--danger2);
  border-color: var(--danger);
  color: var(--text);
}

.ghost-btn{
  background: transparent;
  border-color: var(--border);
  padding: 10px 12px;
}
.link-btn{
  background: transparent;
  border-color: transparent;
  padding: 12px 8px;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.primary-link{
  display:inline-block;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--primary2);
  border: 1px solid var(--primary);
  color: var(--text);
  text-decoration:none;
  font-weight: 700;
}

.field{
  display:block;
  margin-top: 12px;
}
.label{
  display:block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.textarea{
  width:100%;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--soft2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
}
.textarea:focus{
  outline: var(--focus);
  outline-offset: 2px;
}

.toggle-row{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--soft);
  border: 1px solid var(--soft2);
}
.toggle{
  display:flex;
  align-items:center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}
.toggle input{
  width: 18px;
  height: 18px;
}

.segmented, .chips{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  margin-top: 8px;
}
.chip{
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  cursor:pointer;
  font-weight: 700;
  font-size: 13px;
}
.chip[aria-pressed="true"]{
  background: var(--primary2);
  border-color: var(--primary);
}

.radio-group{
  margin-top: 10px;
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.radio{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--soft);
}
.radio input{
  width: 18px;
  height: 18px;
}

.hint{
  margin-top: 12px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--primary);
  background: var(--primary2);
  color: var(--text);
  min-height: 44px;
}

.pause-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
.pause-card{
  text-align:left;
  border-color: var(--soft2);
  background: var(--soft);
  padding: 14px 14px;
}
.pause-card[aria-pressed="true"]{
  border-color: var(--primary);
  background: var(--primary2);
}
.pause-title{
  font-weight: 850;
  margin-bottom: 4px;
  color: var(--text);
}
.pause-desc{
  color: var(--muted);
  font-size: 13px;
}

.timer{
  margin-top: 14px;
  padding: 14px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.14);
}
:root[data-theme="light"] .timer{
  background: var(--soft2);
}

.countdown{
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -1px;
  text-align:center;
  margin: 6px 0 10px;
  color: var(--text);
}
.progress{
  height: 10px;
  border-radius: 999px;
  background: var(--soft2);
  overflow:hidden;
}
.bar{
  height:100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(56,189,248,.92), rgba(167,139,250,.88));
  border-radius: 999px;
}

.list{
  display:flex;
  flex-direction:column;
  gap: 10px;
  margin-top: 14px;
}
.item{
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 18px;
  padding: 12px 12px;
  cursor:pointer;
}
.item-top{
  display:flex;
  justify-content:space-between;
  gap: 12px;
  align-items:center;
}
.badges{
  display:flex;
  gap: 8px;
  flex-wrap:wrap;
}
.badge{
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
}
.badge.primary{
  border-color: var(--primary);
  background: var(--primary2);
}
.badge.danger{
  border-color: var(--danger);
  background: var(--danger2);
}
.item-snippet{
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.item-title,
.item-meta{
  color: var(--text);
  font-weight: 600;
}

.detail{
  margin-top: 10px;
  padding: 12px 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--soft);
}
.kv{
  margin: 8px 0;
  display:flex;
  flex-direction:column;
  gap: 4px;
}
.k{
  color: var(--muted);
  font-size: 12px;
}
.v{
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* Override para o conteúdo de detalhes */
#detailBody{ color: var(--text-detail); }
#detailBody .label{ color: var(--text-detail-label); font-size: 12px; }
#detailBody .value{ color: var(--text-detail); font-size: 14px; font-weight: 600; }
#detailBody .detail-block .value{ white-space: pre-wrap; color: var(--text-detail); }

.empty{
  margin-top: 14px;
  padding: 14px 14px;
  border-radius: 18px;
  border: 1px dashed var(--border);
  background: var(--soft);
}

.bottom-nav{
  position:fixed;
  bottom:0;
  left:0;
  right:0;
  z-index:20;
  display:flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-top: 1px solid var(--soft2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-btn{
  flex:1;
  border-color: var(--border);
  background: var(--soft);
  padding: 12px 10px;
}
.nav-btn[aria-current="page"]{
  background: var(--primary2);
  border-color: var(--primary);
}

.safety{
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.toast{
  position: fixed;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 24px));
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  color: var(--text);
  display:none;
  z-index: 30;
}

.modal{
  position:fixed;
  inset:0;
  display:none;
  z-index: 40;
}
.modal[aria-hidden="false"]{ display:block; }
.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.58);
}
.modal-card{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: min(680px, calc(100% - 24px));
  border-radius: 22px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 16px;
}
.modal-body{ margin-top: 10px; color: var(--text); }
.modal-actions{
  margin-top: 14px;
  display:flex;
  gap: 10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

button:focus-visible, a:focus-visible, input:focus-visible{
  outline: var(--focus);
  outline-offset: 2px;
  border-radius: 14px;
}
button:focus, a:focus, input:focus{
  outline: var(--focus);
  outline-offset: 2px;
}

@media (min-width: 560px){
  .card{ padding: 22px 22px; }
  .pause-grid{ grid-template-columns: 1fr 1fr; }
}