/* ============================================
   Cleartools.in — Tool Page Styles
   ============================================ */

/* Tool Container Layout */
.tool-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.tool-main { min-width: 0; }

.tool-sidebar {
  display: none;
}

/* Sidebar Related Tools */
.sidebar-related-tools {
  background: var(--primary-container);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.sidebar-related-tools h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.sidebar-tools-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-tool-link {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}

.sidebar-tool-link:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
}

.sidebar-tool-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.sidebar-tool-icon svg {
  width: 16px;
  height: 16px;
}

.sidebar-tool-info {
  flex: 1;
  min-width: 0;
}

.sidebar-tool-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.sidebar-tool-desc {
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.3;
  margin-top: 0.125rem;
}

/* Collapse sidebar + its grid column when ads are disabled (empty aside) */
.tool-sidebar:empty { display: none !important; }
.tool-container:has(.tool-sidebar:empty) { grid-template-columns: 1fr !important; }

@media (min-width: 1024px) {
  .tool-container {
    grid-template-columns: 1fr 300px;
    padding: 0 2rem 3rem;
  }
  .tool-sidebar { display: block; }

  .sidebar-related-tools {
    position: sticky;
    top: calc(var(--header-height, 60px) + 1rem);
    z-index: 10;
  }
}

/* ============================================
   Interactive Tool Layout (Decision Tools)
   Two-panel: action left, result right
   ============================================ */

.tool-container.tool-interactive .tool-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .tool-container.tool-interactive .tool-main {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* On interactive tools, collapse outer sidebar — use full width for the two panels */
@media (min-width: 1024px) {
  .tool-container.tool-interactive {
    grid-template-columns: 1fr;
  }
  .tool-container.tool-interactive .tool-sidebar {
    display: block;
  }
}

@media (min-width: 1280px) {
  .tool-container.tool-interactive {
    grid-template-columns: 1fr 280px;
  }
  .tool-container.tool-interactive .tool-main {
    grid-template-columns: 1fr 1fr;
  }
}

.tool-interact-panel,
.tool-output-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.tool-interact-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
}

.tool-output-panel {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* Result pop animation */
@keyframes resultPop {
  0%   { transform: scale(0.85); opacity: 0.5; }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1);    opacity: 1; }
}

/* Stat counter bump */
@keyframes statBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.tool-output-panel .result-value.updating {
  animation: resultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tool-output-panel .result-item .result-value.bumped {
  animation: statBump 0.3s ease;
}

/* Mobile: sticky result highlight below header */
@media (max-width: 767px) {
  .tool-output-panel .result-highlight {
    position: sticky;
    top: var(--header-height, 60px);
    z-index: 40;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: var(--bg-card);
    padding: 1rem;
    margin-bottom: 1rem;
  }
}

/* Mobile: reduce form padding to minimize scroll friction */
@media (max-width: 767px) {
  .tool-form {
    padding: 1rem;
  }

  .tool-interact-panel {
    padding: 1rem;
  }

  /* Keep output panel sticky after user scrolls to it */
  .tool-output-panel {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    z-index: 39;
  }
}

/* Extra small devices (320px): minimize padding and spacing */
@media (max-width: 360px) {
  .tool-form {
    padding: 0.75rem;
  }

  .tool-interact-panel {
    padding: 0.75rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-row {
    gap: 0.75rem;
  }

  .tool-presets {
    gap: 0.25rem;
  }

  .preset-btn {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
  }
}

/* Shared reset button for interactive tools */
.btn-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8125rem;
  transition: border-color 0.2s, color 0.2s;
  align-self: center;
}

.btn-reset:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ============================================
   Tool Form
   ============================================ */

.tool-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-of-type { margin-bottom: 1.5rem; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.form-group .label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}

.form-input::placeholder { color: var(--text-light); }

/* Range slider */
.form-range {
  width: 100%;
  margin-top: 0.5rem;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

/* Keyboard focus state for range slider - WCAG AA enhanced visibility */
.form-range:focus {
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.25), 0 0 0 5px rgba(8, 145, 178, 0.1);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Mobile: Scale up slider thumb for easier interaction */
@media (max-width: 767px) {
  .form-range::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .form-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
}

/* Inline fields */
.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group { flex: 1; }

/* Radio/toggle group */
.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-group label {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: all 0.2s;
  margin: 0;
}

.toggle-group label:last-child { border-right: none; }
.toggle-group input { display: none; }
.toggle-group input:checked + label,
.toggle-group label.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Calculate button */
.btn-calculate {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, outline 0.2s;
}

.btn-calculate:hover { background: var(--primary-dark); }

/* WCAG AA: Enhanced focus visibility for buttons */
.btn-calculate:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  background: var(--primary-dark);
}

/* ============================================
   Tool Result — Standardized Result Card
   ============================================ */

.tool-result,
.result-card {
  background: linear-gradient(135deg, #ecfeff 0%, #f0f9ff 100%);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.08);
}

/* Main result highlight - primary value display */
.result-highlight,
.result-main {
  text-align: center;
  padding: 1.5rem 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(8, 145, 178, 0.15);
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.result-highlight .result-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.result-highlight .result-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.result-item {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.result-item .result-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-item .result-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

@media (min-width: 640px) {
  .result-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Highlighted result item (e.g., better tax regime) */
.result-item-highlight {
  border: 1px solid var(--success);
  background: var(--success-bg);
}
.result-item-highlight .result-value { color: var(--success); }

/* Savings/benefit badge inside result item */
.result-badge {
  display: inline-block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
}

/* EMI summary bar (principal vs interest breakdown) */
.result-summary-bar { display: flex; gap: 0.25rem; height: 8px; border-radius: 4px; overflow: hidden; margin: 0.75rem 0; }
.result-summary-bar div { border-radius: 4px; }
.result-ratio { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 0.25rem; }

/* Result card action buttons */
.result-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(8, 145, 178, 0.15);
  flex-wrap: wrap;
}

.result-note,
.result-formula {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(8, 145, 178, 0.1);
  font-style: italic;
}

/* Copy button */
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover { border-color: var(--primary); color: var(--primary); background: rgba(8, 145, 178, 0.05); }
.btn-copy.copied { border-color: var(--success); color: var(--success); background: rgba(5, 150, 105, 0.05); }
.btn-copy svg { width: 14px; height: 14px; }

/* Export button */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-export:hover { border-color: var(--primary); color: var(--primary); background: rgba(8, 145, 178, 0.05); }
.btn-export:active { transform: scale(0.98); }
.btn-export.exported { border-color: var(--success); color: var(--success); background: rgba(5, 150, 105, 0.05); }
.btn-export svg { width: 14px; height: 14px; }

/* ============================================
   Charts
   ============================================ */

.tool-chart-section {
  margin-top: 1.25rem;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.chart-container h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.chart-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.8125rem;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ============================================
   Result Table
   ============================================ */

.tool-table-section {
  margin-top: 1.25rem;
}

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-container h3 {
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.table-scroll {
  overflow-x: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.result-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.result-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.result-table tbody tr:hover { background: var(--border-light); }

.result-table .text-right { text-align: right; }

.table-expandable { cursor: pointer; }
.table-expandable:hover { background: var(--primary-bg); }
.table-child { display: none; background: var(--bg); }
.table-child.open { display: table-row; }
.table-child td { font-size: 0.75rem; color: var(--text-muted); padding-left: 2rem; }

/* ============================================
   Explanation & Example
   ============================================ */

.tool-content-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.tool-content-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.tool-content-section h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.tool-content-section p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.tool-content-section ul,
.tool-content-section ol {
  margin: 0.5rem 0 0.75rem 1.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.tool-content-section code {
  background: var(--bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.875rem;
}

.formula-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.75rem 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9375rem;
  text-align: center;
  color: var(--text);
}

/* ============================================
   Related Tools
   ============================================ */

.related-tools {
  margin-top: 1.25rem;
}

.related-tools h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .related-tools-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .related-tools-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================
   Tool FAQ (on tool pages)
   ============================================ */

.tool-faq {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.tool-faq h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ============================================
   Ad Slots
   ============================================ */

.ad-slot {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.75rem;
  margin-top: 1.25rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

/* ============================================
   Homepage Tool Embed
   ============================================ */

.hero-tool {
  max-width: 720px;
  margin: 0 auto;
}

.hero-tool .tool-form {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-bg);
}

.hero-tool .tool-result {
  box-shadow: var(--shadow-md);
}

/* ============================================
   Text Tool Styles
   ============================================ */

.text-input-area,
.text-output-area {
  width: 100%;
  min-height: 160px;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.text-input-area:focus,
.text-output-area:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.text-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
}

.text-stat {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.text-stat strong {
  color: var(--text);
  font-weight: 700;
}

/* ============================================
   Sticky Result (Mobile)
   ============================================ */

@media (max-width: 639px) {
  .result-sticky {
    position: sticky;
    bottom: 0;
    z-index: 50;
    margin: 0 -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  }
}

/* ============================================
   Form Design System — Extended Components
   ============================================ */

/* Label row with live value */
.form-label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.375rem; }
.form-label-row label { margin-bottom: 0; }
.form-value-display { font-size: 0.875rem; font-weight: 700; color: var(--primary); }

/* Range min/max labels */
.form-range-labels { display: flex; justify-content: space-between; font-size: 0.6875rem; color: var(--text-light); margin-top: 0.125rem; }

@media (max-width: 640px) {
  .form-range-labels { font-size: 0.875rem; }
}

/* Unit toggle (kg/lbs, cm/ft, years/months) */
.unit-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.625rem; }
.unit-btn { padding: 0.375rem 0.875rem; font-size: 0.8125rem; font-weight: 600; cursor: pointer; background: var(--bg); border: none; color: var(--text-muted); border-right: 1px solid var(--border); transition: all 0.2s; }
.unit-btn:last-child { border-right: none; }
.unit-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* BMI scale visualization */
.bmi-scale { position: relative; height: 1.75rem; border-radius: 1rem; margin: 1.25rem 0 0.375rem; background: linear-gradient(to right, #3b82f6 0%, #22c55e 25%, #eab308 55%, #f97316 75%, #ef4444 100%); }
.bmi-indicator { position: absolute; top: -0.5rem; width: 2px; height: 2.75rem; background: var(--text); transition: left 0.3s; }
.bmi-indicator::after { content: attr(data-value); position: absolute; top: -1.5rem; left: 50%; transform: translateX(-50%); font-size: 0.75rem; font-weight: 700; white-space: nowrap; background: var(--text); color: var(--bg); padding: 0.125rem 0.375rem; border-radius: 0.25rem; }
.bmi-labels { display: flex; justify-content: space-between; font-size: 0.6875rem; color: var(--text-muted); }

/* Height imperial split */
.height-imperial { display: none; }
.height-imperial.active { display: flex; gap: 0.75rem; }
.height-metric.active { display: block; }

/* Preset pills */
.preset-pills { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-top: 0.5rem; }
.preset-pill { padding: 0.3125rem 0.75rem; font-size: 0.8125rem; font-weight: 600; cursor: pointer; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); transition: all 0.2s; }
.preset-pill.active,
.preset-pill:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Calc tabs (percentage calculator) */
.calc-tabs { display: flex; gap: 0; margin-bottom: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.calc-tab { flex: 1; padding: 0.625rem 0.5rem; text-align: center; font-size: 0.8125rem; font-weight: 600; cursor: pointer; background: var(--bg); border: none; color: var(--text-muted); border-right: 1px solid var(--border); transition: all 0.2s; }
.calc-tab:last-child { border-right: none; }
.calc-tab.active { background: var(--primary); color: #fff; }
.calc-panel { display: none; }
.calc-panel.active { display: block; }

/* Result empty/placeholder state */
.result-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1rem; color: var(--text-light); text-align: center; min-height: 100px; gap: 0.625rem; }
.result-placeholder svg { width: 40px; height: 40px; opacity: 0.3; }
.result-placeholder p { font-size: 0.875rem; margin: 0; line-height: 1.4; }

/* Mobile: reduce placeholder height further to minimize scroll friction */
@media (max-width: 767px) {
  .result-placeholder {
    min-height: 80px;
    padding: 1.5rem 1rem;
  }
}

/* Full-width chart/table rows when in tool-interactive grid */
.tool-container.tool-interactive .tool-chart-section,
.tool-container.tool-interactive .tool-table-section { grid-column: 1 / -1; }

/* ============================================
   Dark Mode — Tool Overrides
   ============================================ */

@media (prefers-color-scheme: dark) {
  .tool-container {
    background: var(--bg);
  }

  .tool-interact-panel,
  .tool-output-panel {
    background: var(--bg-card);
    border-color: var(--border);
  }

  .tool-form {
    background: var(--bg-card);
    border-color: var(--border);
  }

  .form-input,
  .form-select,
  .form-textarea {
    background: var(--input-bg);
    border-color: var(--border);
    color: var(--text);
  }

  .form-input:focus,
  .form-select:focus {
    border-color: var(--primary);
    background: var(--input-bg);
  }

  .result-highlight {
    background: #0c2535;
    border-color: #1e4a6b;
  }

  .result-grid-item {
    background: var(--bg-card);
    border-color: var(--border);
  }

  .tool-content-section {
    background: var(--bg-card);
    border-color: var(--border);
  }

  .tool-table th {
    background: var(--input-bg);
    color: var(--text-muted);
  }

  .tool-table td {
    border-color: var(--border);
    color: var(--text);
  }

  .tool-table tr:nth-child(even) td {
    background: #141f30;
  }

  .preset-btn {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-muted);
  }

  .preset-btn.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
  }

  .range-input {
    background: var(--border);
  }

  .tool-faq .faq-item {
    border-color: var(--border);
  }

  .related-tools .tool-card {
    background: var(--bg-card);
    border-color: var(--border);
  }

  .chart-container {
    background: var(--bg-card);
  }

  .tool-trust-bar { border-color: var(--border); }
  .info-tip { background: var(--bg-card); border-color: var(--border); color: var(--text); }
  .loan-amount-highlight { background: var(--primary-bg); border-color: rgba(8,145,178,0.3); }
  .pw-display { background: #0f172a; border-color: var(--border); }
  .qr-canvas-box { background: #fff; border-color: var(--border); }
  .rng-number { background: var(--primary-bg); border-color: rgba(8,145,178,0.3); }
  .remaining-tag { background: var(--bg); border-color: var(--border); }
  .case-buttons .btn-outline { border-color: var(--border); color: var(--text-muted); }
}

/* ============================================
   Tool Trust Bar
   ============================================ */

.tool-trust-bar { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: 0.875rem; }
.tool-trust-bar span { display: flex; align-items: center; gap: 0.3rem; }
.tool-trust-bar .trust-check { color: var(--success); font-weight: 700; font-size: 0.75rem; }

/* ============================================
   Info Tip (tooltip on label)
   ============================================ */

.info-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid var(--border); font-size: 0.6875rem; font-weight: 700; color: var(--text-muted); cursor: default; vertical-align: middle; margin-left: 0.25rem; transition: border-color 0.2s, color 0.2s; }
.info-tip:hover { border-color: var(--primary); color: var(--primary); }
.info-tip::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 0.5rem); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: 0.75rem; font-weight: 400; line-height: 1.4; padding: 0.5rem 0.75rem; border-radius: var(--radius); white-space: normal; width: 220px; text-align: left; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 10; }
.info-tip:hover::after { opacity: 1; }

/* ============================================
   EMI Preset Loan-Type Buttons
   ============================================ */

.tool-presets { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.preset-btn { padding: 0.375rem 0.875rem; font-size: 0.8125rem; font-weight: 600; cursor: pointer; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); transition: all 0.2s; }
.preset-btn.active, .preset-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Mobile: Reduce preset button gap for 2-column wrap */
@media (max-width: 640px) {
  .tool-presets { gap: 0.375rem; }
}

/* ============================================
   320px Breakpoint — Extreme Small Phones
   ============================================ */

@media (max-width: 320px) {
  /* Container: tighter padding */
  .tool-container {
    padding: 0 0.5rem 2rem;
    gap: 1rem;
  }

  /* Form: reduce padding */
  .tool-form {
    padding: 1rem;
  }

  /* Form groups: tighter spacing */
  .form-group {
    margin-bottom: 1rem;
  }

  /* Labels: slightly smaller for extreme small screens */
  .form-group label {
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
  }

  /* Inputs: adjust padding */
  .form-input,
  .form-select {
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
  }

  /* Button: reduce padding */
  .btn-calculate {
    padding: 0.75rem;
    font-size: 0.9375rem;
  }

  /* Result card: reduce padding */
  .tool-result,
  .result-card {
    padding: 1rem;
  }

  /* Result highlight: tighter */
  .result-highlight,
  .result-main {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  /* Sidebar: adjust for small screen */
  .sidebar-related-tools {
    padding: 1rem;
  }

  /* Preset pills: tighter gap */
  .preset-pills { gap: 0.25rem; }
  .preset-pill { padding: 0.25rem 0.625rem; font-size: 0.75rem; }

  /* Toggle buttons: reduce padding */
  .toggle-group label {
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
  }

  /* Result grid: single column on 320px */
  .result-grid {
    grid-template-columns: 1fr;
  }

  /* Feature grid: stack */
  .features-grid {
    grid-template-columns: 1fr;
  }

  /* Dice grid: reduce gap */
  .dice-grid { gap: 0.5rem; }
  .die { width: 56px; height: 56px; }

  /* Wheel: smaller on 320px */
  .wheel-container { width: 200px; height: 200px; }
}

/* ============================================
   Home Loan — Loan Amount Highlight
   ============================================ */

.loan-amount-highlight { background: var(--primary-bg); border: 1px solid var(--primary-light); border-radius: var(--radius); padding: 0.875rem 1.25rem; margin-bottom: 1.25rem; text-align: center; }
.loan-amount-highlight .lah-label,
.loan-amount-highlight .loan-amount-label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.25rem; }
.loan-amount-highlight .lah-value,
.loan-amount-highlight .loan-amount-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.loan-amount-highlight .loan-amount-calc { font-size: 0.75rem; color: var(--text-light); margin-top: 0.25rem; }

/* ============================================
   Password Generator
   ============================================ */

.pw-display { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; margin-bottom: 1rem; word-break: break-all; }
.pw-text { font-family: 'SF Mono','Fira Code','Roboto Mono',monospace; font-size: 1.25rem; font-weight: 600; letter-spacing: 0.05em; line-height: 1.6; color: var(--text); }
.pw-actions { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.75rem; }
.pw-strength-bar { height: 0.375rem; border-radius: 0.25rem; background: var(--border); margin-top: 0.75rem; overflow: hidden; }
.pw-strength-fill { height: 100%; border-radius: 0.25rem; transition: width 0.3s, background 0.3s; }
.pw-strength-label { font-size: 0.8125rem; font-weight: 600; margin-top: 0.375rem; }
.pw-options { display: flex; flex-direction: column; gap: 0.75rem; }
.pw-option { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9375rem; }
.pw-option input[type="checkbox"] { width: auto; accent-color: var(--primary); }
.pw-length-display { font-weight: 700; font-size: 1.125rem; color: var(--primary); min-width: 2.5rem; text-align: center; }

/* ============================================
   QR Code Generator
   ============================================ */

.qr-output-wrap { text-align: center; padding: 1.25rem 0; }
.qr-canvas-box { display: inline-block; padding: 1rem; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1rem; }
.qr-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }

/* ============================================
   Random Number Generator
   ============================================ */

.rng-result-numbers { display: flex; flex-wrap: wrap; gap: 0.625rem; justify-content: center; margin: 1rem 0; }
.rng-number { min-width: 3.5rem; padding: 0.625rem 1rem; background: var(--primary-bg); border: 1px solid var(--primary-light); border-radius: var(--radius); font-size: 1.5rem; font-weight: 800; color: var(--primary); text-align: center; }
.rng-history { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.rng-hist-item { font-size: 0.8125rem; color: var(--text-muted); padding: 0.25rem 0; border-bottom: 1px solid var(--border-light); }

/* ============================================
   Random Name Picker
   ============================================ */

.picker-result-name { font-size: 2rem; font-weight: 800; color: var(--primary); text-align: center; padding: 1.5rem 1rem; word-break: break-word; line-height: 1.2; }
.picker-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1rem; }
.remaining-list { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.75rem; }
.remaining-tag { padding: 0.25rem 0.625rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; font-size: 0.8125rem; color: var(--text-muted); }
.remaining-tag.picked { text-decoration: line-through; opacity: 0.4; }

/* ============================================
   Dice Roller
   ============================================ */

.dice-count-select { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.dice-count-btn { width: 40px; height: 40px; border-radius: 8px; border: 2px solid var(--border); background: var(--bg); cursor: pointer; font-weight: 700; font-size: 1rem; color: var(--text); transition: all 0.15s; }
.dice-count-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.dice-grid { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; min-height: 80px; align-items: center; }
.die { width: 68px; height: 68px; background: #fff; border: 3px solid #e2e8f0; border-radius: 12px; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); padding: 7px; gap: 3px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); transition: transform 0.2s; }
.die.rolling { animation: dieShake 0.5s; }
@keyframes dieShake { 0%,100%{transform:rotate(0)} 20%{transform:rotate(-15deg)} 40%{transform:rotate(15deg)} 60%{transform:rotate(-10deg)} 80%{transform:rotate(10deg)} }
.dot { border-radius: 50%; background: var(--text); width: 100%; height: 100%; }
.dot.empty { background: transparent; }
.roll-hist-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 150px; overflow-y: auto; }
.roll-hist-item { font-size: 0.8125rem; color: var(--text-muted); padding: 0.25rem 0.5rem; background: var(--bg); border-radius: 4px; display: flex; justify-content: space-between; }

/* ============================================
   Coin Flip
   ============================================ */

.coin { width: 110px; height: 110px; position: relative; perspective: 600px; cursor: pointer; flex-shrink: 0; }
.coin-inner { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.6s; border-radius: 50%; }
.coin.flipping .coin-inner { animation: coinFlip 0.8s ease; }
@keyframes coinFlip { 0%{transform:rotateY(0)} 25%{transform:rotateY(720deg)} 50%{transform:rotateY(1440deg)} 75%{transform:rotateY(1800deg)} 100%{transform:rotateY(var(--flip-end,0))} }
.coin-face, .coin-back { position: absolute; width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.25rem; font-weight: 700; backface-visibility: hidden; }
.coin-face { background: linear-gradient(135deg,#f59e0b,#fcd34d); color: #92400e; box-shadow: 0 4px 15px rgba(245,158,11,0.4); }
.coin-back { background: linear-gradient(135deg,#d97706,#f59e0b); color: #78350f; transform: rotateY(180deg); box-shadow: 0 4px 15px rgba(217,119,6,0.4); }
.flip-history { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.flip-badge { padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.flip-badge.heads { background: #fef3c7; color: #92400e; }
.flip-badge.tails { background: #e0f2fe; color: #075985; }

/* ============================================
   Yes / No Wheel
   ============================================ */

.wheel-container { position: relative; width: 260px; height: 260px; flex-shrink: 0; }
.wheel-pointer { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent; border-top: 24px solid #1e293b; z-index: 10; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
canvas#yes-no-canvas { border-radius: 50%; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.wheel-result { font-size: 2rem; font-weight: 700; min-height: 2.75rem; text-align: center; transition: color 0.3s; }
.wheel-result.yes { color: #059669; }
.wheel-result.no { color: #dc2626; }
.wheel-result.maybe { color: #d97706; }
.wheel-options { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.wheel-opt-btn { padding: 0.35rem 0.75rem; border-radius: 999px; border: 2px solid var(--border); background: var(--bg); cursor: pointer; font-size: 0.8125rem; font-weight: 600; transition: all 0.15s; }
.wheel-opt-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }
@media (max-width: 400px) { .wheel-container { width: 220px; height: 220px; } }

/* ============================================
   Case Converter — Action Buttons Row
   ============================================ */

.case-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

/* ============================================
   JSON Formatter — Monospace Output
   ============================================ */

.json-output { background: var(--bg); padding: 1rem; border-radius: var(--radius); overflow-x: auto; font-size: 0.8125rem; line-height: 1.5; max-height: 500px; overflow-y: auto; margin: 0; font-family: 'SF Mono','Fira Code','Roboto Mono',monospace; }
