/* Multi-Calculator Web Suite Styles */

.calc-nav {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 12px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.calc-chip {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.calc-chip:hover, .calc-chip.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.calc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow);
  position: relative;
}

.calc-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.calc-card .ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(15, 82, 186, 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.calc-card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.calc-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.fav-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--muted);
  transition: color 0.15s ease;
}

.fav-btn.active {
  color: #ffb300;
}

/* Calculator View Layout */
.calc-container {
  max-width: 800px;
  margin: 0 auto;
}

.calc-header {
  margin-bottom: 24px;
}

.calc-header h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 0 8px;
}

.calc-header p {
  color: var(--muted);
  margin: 0;
}

.calc-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.input-field {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--fg);
  font-size: 1.1rem;
  font-family: inherit;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent);
}

.select-field {
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--fg);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}

/* Keypad Grid for Basic / Scientific */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.keypad-btn {
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.keypad-btn:hover {
  background: var(--line);
}

.keypad-btn.op {
  background: rgba(15, 82, 186, 0.12);
  color: var(--accent);
}

.keypad-btn.equals {
  background: var(--accent);
  color: var(--accent-ink);
}

.keypad-display {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  font-size: 2rem;
  font-weight: 800;
  text-align: right;
  word-break: break-all;
  min-height: 70px;
  margin-bottom: 16px;
}

/* Result Panel */
.result-panel {
  background: rgba(15, 82, 186, 0.08);
  border: 1px solid rgba(15, 82, 186, 0.2);
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
}

.result-main {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 8px;
}

.result-meta {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

.formula-box {
  background: var(--bg);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.95rem;
  margin-top: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.history-item {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.history-item span {
  font-weight: 600;
}

/* ---- Spec-driven layout: categories, forms, results, settings ------------------------------ */
.calc-muted { color: var(--muted); }
.calc-small { font-size: .88rem; }
.calc-search { width: 100%; max-width: 640px; font-size: 1.05rem; padding: 14px 18px; }
.calc-search-wrap { margin-bottom: 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.calc-nav { flex-wrap: wrap; overflow: visible; }
.calc-chip:focus-visible, .keypad-btn:focus-visible, .calc-btn:focus-visible, .calc-card:focus-visible, .fav-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.calc-chip { min-height: 44px; }
.calc-count { opacity: .75; font-weight: 500; margin-left: 4px; }
.cat-section { margin-bottom: 36px; }
.cat-section > h2 { margin: 0 0 4px; font-size: 1.35rem; }
.cat-section > p { margin: 0 0 14px; color: var(--muted); max-width: 70ch; }
.calc-card { min-height: 88px; }
.calc-card .cat { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.calc-card.planned { opacity: .6; box-shadow: none; cursor: default; }
.calc-card.planned:hover { transform: none; border-color: var(--line); }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); width: fit-content; }
.fav-btn { min-width: 44px; min-height: 44px; top: 6px; right: 6px; }
.calc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.calc-btn { min-height: 46px; padding: 10px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font: inherit; font-weight: 700; cursor: pointer; }
.calc-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.calc-btn:disabled { opacity: .5; cursor: not-allowed; }
.calc-back { margin-bottom: 14px; }
.hint { display: block; font-size: .82rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
.unit-tag { font-weight: 400; color: var(--muted); }
.form-group textarea.input-field { width: 100%; min-height: 96px; resize: vertical; font-family: inherit; }
.form-group .input-field, .form-group .select-field { width: 100%; min-height: 48px; box-sizing: border-box; }
.field-error { color: #c62828; font-size: .85rem; margin-top: 4px; }
@media (prefers-color-scheme: dark) { .field-error, .error-banner { color: #ff8a80; } }
.error-banner { background: rgba(198, 40, 40, .1); border: 1px solid rgba(198, 40, 40, .35); color: #c62828; padding: 12px 16px; border-radius: 12px; white-space: pre-line; }
.warn-banner { background: rgba(255, 179, 0, .14); border: 1px solid rgba(255, 179, 0, .5); padding: 12px 16px; border-radius: 12px; margin-top: 12px; font-size: .92rem; }
.res-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.res-row:last-child { border-bottom: 0; }
.res-row .k { color: var(--muted); }
.res-row .v { font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.res-row.main .v { font-size: 1.7rem; color: var(--accent); font-weight: 900; }
.res-row.main { flex-direction: column; align-items: flex-start; gap: 2px; }
.res-row.main .v { text-align: left; }
.calc-details { margin-top: 14px; }
.calc-details summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.calc-details ul, .calc-details ol { margin: 6px 0 0 20px; padding: 0; color: var(--muted); }
.tbl-wrap { overflow-x: auto; max-height: 360px; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; }
.tbl { border-collapse: collapse; width: 100%; font-size: .9rem; }
.tbl th, .tbl td { padding: 6px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: var(--bg-soft); }
.tbl.cal td, .tbl.cal th { text-align: center; }
.keypad.sci { grid-template-columns: repeat(5, 1fr); }
.keypad-btn { min-height: 52px; padding: 10px; }
.keypad-btn.fn { font-size: .95rem; }
.keypad-display { overflow-wrap: anywhere; }
.keypad-expr { width: 100%; box-sizing: border-box; font-size: 1.3rem; text-align: right; margin-bottom: 8px; }
.display-sub { color: var(--muted); font-size: .9rem; min-height: 1.3em; text-align: right; }
.history-item { gap: 10px; }
.history-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.history-item button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; min-width: 44px; min-height: 44px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 600px) { .calc-body { padding: 18px; } .keypad { gap: 6px; } .result-main, .res-row.main .v { font-size: 1.5rem; } }

/* Print or save as PDF: only the calculator and its result, without the site's menus, guides and links. */
@media print {
  .top, .foot, .page-band, .app-band, .related, .faq, .toc, .skip, .calc-nav, .calc-search-wrap, #settings-panel,
  .calc-back, #btn-fav, #btn-link, #btn-print, #btn-share, #btn-copy, #copy-note, .calc-actions, section[aria-labelledby], .calc-small { display: none !important; }
  body, main { background: #fff !important; color: #000 !important; }
  .calc-single .calc-header > h2 { position: static !important; width: auto !important; height: auto !important; overflow: visible !important; clip-path: none !important; margin: 0 0 12px; font-size: 20pt; }
  .result-panel { break-inside: avoid; border: 1px solid #000; }
  .calc-details { display: block; }
  input, select, textarea { border: 0 !important; border-bottom: 1px solid #000 !important; background: none !important; }
}
