/* v1.1.0 — Estilo tipo Google Calc (oscuro), “pills”, grid 7 columnas */
.ccch-shell{
  --bg: #0f1115;
  --panel: #202124;
  --pill: #303134;
  --pill2: #2b2c2f;
  --pillOp: #2a3340;
  --border: rgba(255,255,255,0.06);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.65);
  --eq: #8ab4f8;
  --danger: rgba(255,255,255,0.08);
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15,17,21,0.98), rgba(15,17,21,0.92));
  border: 1px solid var(--border);
  box-shadow: 0 16px 60px rgba(0,0,0,0.45);
  color: var(--text);
}

.ccch-title{
  font-weight: 800;
  font-size: 18px;
  margin: 2px 2px 12px 2px;
  color: var(--text);
}

.ccch-calc{
  display: grid;
  gap: 12px;
}

.ccch-display{
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  padding: 14px 14px 12px 14px;
  border: 1px solid var(--border);
}

.ccch-history-btn{
  position:absolute;
  left: 10px;
  top: 10px;
  width: 42px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
}
.ccch-history-btn:hover{ background: rgba(255,255,255,0.06); }

.ccch-history-ico{
  display:inline-block;
  transform: translateY(-1px);
  opacity: 0.9;
}

.ccch-display-inner{
  padding-left: 46px;
  padding-right: 46px;
}

.ccch-expr{
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ccch-result{
  margin-top: 6px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.2px;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ccch-status{
  min-height: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.ccch-history{
  background: rgba(32,33,36,0.90);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.ccch-history-top{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ccch-history-title{
  font-weight: 800;
}
.ccch-history-list{
  display:grid;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable both-edges;
}
.ccch-history-item{
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 10px 12px;
  cursor: pointer;
}
.ccch-history-item:hover{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
}
.ccch-history-item .expr{
  font-size: 12px;
  color: var(--muted);
  overflow:hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ccch-history-item .res{
  margin-top: 6px;
  font-size: 16px;
  font-weight: 900;
  text-align:right;
}

.ccch-keys{
  display:grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.ccch-pill{
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--pill);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor:pointer;
  user-select:none;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.ccch-pill:hover{ background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.10); }
.ccch-pill:active{ transform: translateY(1px); }

.ccch-pill-op{
  background: rgba(138,180,248,0.10);
  border-color: rgba(138,180,248,0.18);
}
.ccch-pill-eq{
  background: var(--eq);
  border-color: rgba(138,180,248,0.65);
  color: #0b0f17;
  font-weight: 900;
}
.ccch-pill-danger{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
}
.ccch-pill-ghost{
  background: rgba(255,255,255,0.02);
  border-color: rgba(255,255,255,0.06);
  color: var(--muted);
}

.ccch-pill-toggle[aria-pressed="true"]{
  background: rgba(138,180,248,0.18);
  border-color: rgba(138,180,248,0.30);
  color: rgba(255,255,255,0.95);
}

.ccch-seg{
  grid-column: span 2;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--pill2);
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 0 8px;
}
.ccch-seg-btn{
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  cursor:pointer;
}
.ccch-seg-btn[aria-pressed="true"]{
  background: rgba(138,180,248,0.18);
  border-color: rgba(138,180,248,0.28);
}
.ccch-seg-div{
  color: rgba(255,255,255,0.35);
  font-weight: 800;
  padding: 0 2px;
}

@media (max-width: 820px){
  .ccch-shell{ padding: 12px; }
  .ccch-result{ font-size: 30px; }
  .ccch-keys{ grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .ccch-seg{ grid-column: span 2; }
}
@media (max-width: 480px){
  .ccch-keys{ grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
  .ccch-pill{ height: 46px; }
  .ccch-seg{ grid-column: span 2; height: 46px; }
  .ccch-seg-btn{ height: 36px; padding: 0 12px; }
}


/* --- Widget inferior: Resolución de problemas (panel) --- */
.ccch-solver{
  margin-top: 12px;
  background: rgba(32,33,36,0.88);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 12px;
}
.ccch-solver-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ccch-solver-title{
  font-weight: 900;
  letter-spacing: .2px;
}
.ccch-tabs{
  display:flex;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 10px;
  margin-bottom: 10px;
  overflow:auto;
  scrollbar-gutter: stable both-edges;
}
.ccch-tab{
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.88);
  font-weight: 800;
  cursor:pointer;
  white-space: nowrap;
}
.ccch-tab[aria-selected="true"]{
  background: rgba(138,180,248,0.18);
  border-color: rgba(138,180,248,0.28);
}
.ccch-tabpanes[data-collapsed="1"] .ccch-tools{
  display:none;
}
.ccch-tools{
  display:grid;
  gap: 12px;
}
.ccch-tool{
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  padding: 12px;
}
.ccch-tool-name{ font-weight: 900; }
.ccch-tool-desc{ margin-top: 4px; font-size: 12px; color: rgba(255,255,255,0.65); }

.ccch-form{
  margin-top: 10px;
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items:end;
}
.ccch-form-wide{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ccch-form label{
  display:flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.70);
}
.ccch-form input{
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(15,17,21,0.75);
  color: rgba(255,255,255,0.92);
  padding: 0 10px;
  outline: none;
}
.ccch-form input:focus{
  border-color: rgba(138,180,248,0.35);
  box-shadow: 0 0 0 3px rgba(138,180,248,0.10);
}

.ccch-out{
  margin-top: 10px;
  font-weight: 800;
  color: rgba(255,255,255,0.90);
  line-height: 1.45;
}
.ccch-out .muted{ color: rgba(255,255,255,0.65); font-weight: 700; }
.ccch-out code{
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 8px;
}

.ccch-presets{
  display:flex;
  gap: 10px;
  margin-top: 10px;
  overflow:auto;
  padding-bottom: 2px;
}
.ccch-chip{
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(15,17,21,0.55);
  color: rgba(255,255,255,0.88);
  font-weight: 800;
  cursor:pointer;
  white-space: nowrap;
}
.ccch-chip:hover{ background: rgba(255,255,255,0.06); }

@media (max-width: 820px){
  .ccch-form{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ccch-form-wide{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* --- Solver compacto: por defecto colapsado (solo "Resolución..." + "Ver más") --- */
.ccch-solver{
  padding: 10px;
}
.ccch-solver-title{
  font-size: 13px;
  font-weight: 900;
  color: rgba(255,255,255,0.86);
}
.ccch-solver-toggle{
  height: 34px;
}

.ccch-solver[data-collapsed="1"]{
  padding: 10px;
}
.ccch-solver[data-collapsed="1"] .ccch-solver-body{
  display:none;
}
.ccch-solver[data-collapsed="1"] .ccch-presets{
  display:none;
}


/* --- Tema (oscuro/claro/auto) + botón de tema (sin solapes) --- */
.ccch-shell[data-theme="claro"]{
  --bg: #f4f6fb;
  --panel: #ffffff;
  --pill: #eef2f6;
  --pill2: #e7ecf2;
  --pillOp: rgba(26,115,232,0.10);
  --border: rgba(0,0,0,0.10);
  --text: rgba(0,0,0,0.90);
  --muted: rgba(0,0,0,0.60);
  --eq: #1a73e8;
  --danger: rgba(0,0,0,0.08);
  background: linear-gradient(180deg, rgba(244,246,251,0.98), rgba(244,246,251,0.90));
  box-shadow: 0 16px 60px rgba(0,0,0,0.16);
}

@media (prefers-color-scheme: light){
  .ccch-shell[data-theme="auto"]{
    --bg: #f4f6fb;
    --panel: #ffffff;
    --pill: #eef2f6;
    --pill2: #e7ecf2;
    --pillOp: rgba(26,115,232,0.10);
    --border: rgba(0,0,0,0.10);
    --text: rgba(0,0,0,0.90);
    --muted: rgba(0,0,0,0.60);
    --eq: #1a73e8;
    --danger: rgba(0,0,0,0.08);
    background: linear-gradient(180deg, rgba(244,246,251,0.98), rgba(244,246,251,0.90));
    box-shadow: 0 16px 60px rgba(0,0,0,0.16);
  }
}

/* Botón selector de tema: derecha, sin tapar historial */
.ccch-theme-btn{
  position:absolute;
  left: 10px;
  top: 52px;
  width: 42px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 3;
}

/* Claro: fondo coherente */
.ccch-shell[data-theme="claro"] .ccch-theme-btn{
  background: rgba(0,0,0,0.04);
}
@media (prefers-color-scheme: light){
  .ccch-shell[data-theme="auto"] .ccch-theme-btn{
    background: rgba(0,0,0,0.04);
  }
}

.ccch-theme-btn:hover{ transform: translateY(-1px); }
.ccch-theme-ico{ font-weight: 900; opacity: .95; }

/* Botones vacíos (noop): invisibles y no clic */
.ccch-pill[data-action="noop"]{
  opacity: 0 !important;
  pointer-events: none !important;
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}



/* ============================================================
   Ajustes de UX: tema claro coherente + hover legible
   ============================================================ */

/* Hover coherente (evita botones "blancos" que pierden contraste) */
.ccch-shell .ccch-pill:hover{
  background: var(--ccch-key-bg-2);
  border-color: var(--ccch-key-border);
}
.ccch-shell .ccch-chip:hover{
  background: var(--ccch-key-bg-2);
}

/* Tema claro: historial y panel "Ver más" sin fondos oscuros */
.ccch-shell[data-theme="claro"] .ccch-history{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.10);
}
.ccch-shell[data-theme="claro"] .ccch-history-item{
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}
.ccch-shell[data-theme="claro"] .ccch-history-item:hover{
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.12);
}
.ccch-shell[data-theme="claro"] .ccch-history-btn{
  background: rgba(0,0,0,0.04);
}
.ccch-shell[data-theme="claro"] .ccch-history-btn:hover{
  background: rgba(0,0,0,0.07);
}

/* Solver (Ver más) en claro */
.ccch-shell[data-theme="claro"] .ccch-solver{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.10);
}
.ccch-shell[data-theme="claro"] .ccch-solver-title{
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-tab{
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.10);
  color: rgba(0,0,0,0.78);
}
.ccch-shell[data-theme="claro"] .ccch-tab:hover{
  background: rgba(0,0,0,0.06);
}
.ccch-shell[data-theme="claro"] .ccch-tab[aria-selected="true"]{
  background: rgba(26,115,232,0.14);
  border-color: rgba(26,115,232,0.32);
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-form label{
  color: rgba(0,0,0,0.65);
}
.ccch-shell[data-theme="claro"] .ccch-form input{
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.10);
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-form input::placeholder{
  color: rgba(0,0,0,0.45);
}
.ccch-shell[data-theme="claro"] .ccch-out{
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-out .muted{
  color: rgba(0,0,0,0.60);
}
.ccch-shell[data-theme="claro"] .ccch-out code{
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.10);
  color: rgba(0,0,0,0.86);
}

/* Auto + sistema en claro: mismos overrides */
@media (prefers-color-scheme: light){
  .ccch-shell[data-theme="auto"] .ccch-history{
    background: rgba(255,255,255,0.92);
    border-color: rgba(0,0,0,0.10);
  }
  .ccch-shell[data-theme="auto"] .ccch-history-item{
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
  }
  .ccch-shell[data-theme="auto"] .ccch-history-item:hover{
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.12);
  }
  .ccch-shell[data-theme="auto"] .ccch-history-btn{
    background: rgba(0,0,0,0.04);
  }
  .ccch-shell[data-theme="auto"] .ccch-history-btn:hover{
    background: rgba(0,0,0,0.07);
  }
  .ccch-shell[data-theme="auto"] .ccch-solver{
    background: rgba(255,255,255,0.92);
    border-color: rgba(0,0,0,0.10);
  }
  .ccch-shell[data-theme="auto"] .ccch-solver-title{
    color: rgba(0,0,0,0.86);
  }
  .ccch-shell[data-theme="auto"] .ccch-tab{
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.10);
    color: rgba(0,0,0,0.78);
  }
  .ccch-shell[data-theme="auto"] .ccch-tab:hover{
    background: rgba(0,0,0,0.06);
  }
  .ccch-shell[data-theme="auto"] .ccch-tab[aria-selected="true"]{
    background: rgba(26,115,232,0.14);
    border-color: rgba(26,115,232,0.32);
    color: rgba(0,0,0,0.86);
  }
  .ccch-shell[data-theme="auto"] .ccch-form label{
    color: rgba(0,0,0,0.65);
  }
  .ccch-shell[data-theme="auto"] .ccch-form input{
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.10);
    color: rgba(0,0,0,0.86);
  }
  .ccch-shell[data-theme="auto"] .ccch-out{
    color: rgba(0,0,0,0.86);
  }
  .ccch-shell[data-theme="auto"] .ccch-out .muted{
    color: rgba(0,0,0,0.60);
  }
  .ccch-shell[data-theme="auto"] .ccch-out code{
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.10);
    color: rgba(0,0,0,0.86);
  }
}


/* --- FIX v1.2.8: Modo claro legible (sin texto que desaparece en hover/click) --- */
.ccch-shell[data-theme="claro"] .ccch-solver-title{
  color: rgba(0,0,0,0.80);
}
.ccch-shell[data-theme="claro"] .ccch-tabs{
  border-bottom-color: rgba(0,0,0,0.10);
}
.ccch-shell[data-theme="claro"] .ccch-tab{
  border-color: rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.03);
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-tab:hover{
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-chip{
  border-color: rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.03);
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-chip:hover{
  background: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-tool{
  border-color: rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.02);
}
.ccch-shell[data-theme="claro"] .ccch-tool-desc{
  color: rgba(0,0,0,0.62);
}
.ccch-shell[data-theme="claro"] .ccch-out{
  color: rgba(0,0,0,0.86);
}
.ccch-shell[data-theme="claro"] .ccch-pane{
  color: rgba(0,0,0,0.86);
}


/* --- FIX v1.2.9: Teclas principales en claro siempre legibles (hover/active sin invertir texto) --- */
.ccch-shell[data-theme="claro"] .ccch-pill,
.ccch-shell[data-theme="claro"] .ccch-pill:hover,
.ccch-shell[data-theme="claro"] .ccch-pill:active,
.ccch-shell[data-theme="claro"] .ccch-pill:focus{
  color: rgba(0,0,0,0.90) !important;
}
.ccch-shell[data-theme="claro"] .ccch-pill-eq{
  color: #0b0f17 !important;
}

/* --- Ajustes de contraste (tema claro): evitar texto blanco en toggles activos --- */
.ccch-shell[data-theme="claro"] .ccch-pill-toggle[aria-pressed="true"]{
  color: rgba(0,0,0,0.90) !important;
  background: rgba(26,115,232,0.14) !important;
  border-color: rgba(26,115,232,0.28) !important;
}
@media (prefers-color-scheme: light){
  .ccch-shell[data-theme="auto"] .ccch-pill-toggle[aria-pressed="true"]{
    color: rgba(0,0,0,0.90) !important;
    background: rgba(26,115,232,0.14) !important;
    border-color: rgba(26,115,232,0.28) !important;
  }
}

/* --- Botón “Ver más”: nunca partir texto (móvil / escritorio) --- */
.ccch-solver-toggle{
  white-space: nowrap;
  min-width: 92px;
  padding: 0 16px;
  line-height: 1;
}

/* --- Responsive móvil reforzado (sin “dos versiones”; una UI que se adapta) --- */
@media (max-width: 520px){
  .ccch-shell{ padding: 10px; }
  .ccch-title{ font-size: 18px; }
  .ccch-display{
    border-radius: 16px;
    padding: 12px 12px 10px 12px;
  }
  .ccch-display-inner{
    padding-left: 42px;
    padding-right: 42px;
  }
  .ccch-expr{ font-size: 11px; }
  .ccch-result{ font-size: 28px; }
  .ccch-keys{ gap: 8px; }
  .ccch-pill{ height: 40px; font-size: 13px; }
  .ccch-seg{ height: 40px; }
  .ccch-seg-btn{ height: 34px; padding: 0 10px; font-size: 12px; }
  .ccch-solver{
    border-radius: 14px;
    padding: 10px;
  }
  .ccch-solver-head{
    gap: 8px;
  }
  .ccch-solver-title{
    font-size: 13px;
    line-height: 1.2;
  }
  .ccch-solver-toggle{
    height: 36px;
    min-width: 96px;
    font-size: 12px;
  }
}
