:root {
  --shadow-light: #ffffff;
  --shadow-dark: #c5c9cc;
  --btn-bg: #e8ecf0;
  --blue: #1877f2;
}

body.light {
  background-color: #e8ecf0;
  color: #333;
  --shadow-light: #ffffff;
  --shadow-dark: #c5c9cc;
  --btn-bg: #e8ecf0;
}

body.dark {
  background-color: #1e1f22;
  color: #f2f2f2;
  --shadow-light: #2a2b2f;
  --shadow-dark: #101113;
  --btn-bg: #1e1f22;
}

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden; /* Prevent horizontal page scrolling */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  background: inherit;
  z-index: 999;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 16px;
  background: var(--btn-bg);
  box-shadow:
    5px 

5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
  border: none;
  cursor: pointer;
  color: inherit;
  transition: all 0.3s ease-in-out;
  z-index: 1000;
}

.scroll-center-wrapper {
  width: 300px;
  height: 100%;
  overflow-x: auto;
  display: flex;
  align-items: center;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 0 20px;
  mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
}

.scroll-center-wrapper::-webkit-scrollbar {
  display: none;
}

.scroll-buttons {
  display: flex;
  align-items: center;
  gap: 16px;
}

.phantom {
  width: 120px;
  flex-shrink: 0;
}

.neu-button {
  min-width: 140px;
  height: 42px;
  font-size: 13px;
  background: var(--btn-bg);
  border-radius: 12px;
  border: none;
  color: var(--blue);
  scroll-snap-align: center;
  cursor: pointer;
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
  opacity: 0.3;
  transform: scale(0.9);
  transition: all 0.3s ease-in-out;
}

.neu-button.focused {
  opacity: 1;
  transform: scale(1.1);
}

#output-container {
  position: relative;
  padding: 120px 20px 100px;
  margin-right: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scrolling of container */
  scroll-behavior: smooth;
  box-sizing: border-box;
}

#output-container::-webkit-scrollbar {
  width: 10px;
}

#output-container::-webkit-scrollbar-track {
  background: transparent;
}

#output-container::-webkit-scrollbar-thumb {
  background-color: #1877f2;
  border-radius: 8px;
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
}

.scroll-arrow {
  position: fixed;
  right: 15px;
  width: 40px;
  height: 40px;
  font-size: 20px;
  color: white;
  background-color: #1877f2;
  border: none;
  border-radius: 50%;
  box-shadow:
    4px 4px 6px var(--shadow-dark),
    -4px -4px 6px var(--shadow-light);
  cursor: pointer;
  z-index: 1000;
  transition: all 0.2s ease;
}

.scroll-arrow:hover {
  transform: scale(1.15);
  background-color: #0f5cc2;
}

#scrollTopBtn {
  bottom: 100px;
}

#scrollBottomBtn {
  bottom: 40px;
}

.output-card {
  position: relative;
  background: var(--btn-bg);
  padding: 6px 20px;
  border-radius: 14px;
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  margin-bottom: 10px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-x: auto; /* Allow horizontal scrolling within card */
  max-width: 100%; /* Ensure card doesn't exceed parent width */
  transition: all 0.3s ease-in-out;
}

.output-card .query {
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 8px;
  display: block;
}

.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: inherit;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  gap: 10px;
  z-index: 999;
  box-sizing: border-box;
}

.footer input {
  flex: 1;
  height: 40px;
  padding: 0 15px;
  border-radius: 12px;
  border: none;
  background: var(--btn-bg);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  color: inherit;
  font-size: 14px;
  outline: none;
  max-width: calc(100% - 70px);
  box-sizing: border-box;
}

.footer button {
  min-width: 50px;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: var(--btn-bg);
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
  cursor: pointer;
  color: var(--blue);
  font-size: 16px;
  transition: all 0.3s ease-in-out;
}

.dots-loader {
  display: inline-block;
  vertical-align: middle;
  width: 1em;
  height: 1em;
  font-size: 16px;
  position: relative;
}

.dots-loader::after {
  content: '...';
  animation: dots 1.2s steps(3, end) infinite;
  font-weight: bold;
  color: inherit;
}

@keyframes dots {
  0%   { content: ''; }
  33%  { content: '.'; }
  66%  { content: '..'; }
  100% { content: '...'; }
}

.section-content {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.section-content.fade-in {
  opacity: 1;
}

.risk-chart-wrapper {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

#chat-output {
  overflow-y: auto;
  max-height: 100%;
  height: 100%;
  scroll-behavior: smooth;
}

.risk-pie {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #e0e0e0;
  box-shadow:
    inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-weight: bold;
  font-size: 20px;
  transition: all 0.4s ease;
}

.risk-pie .risk-text {
  position: absolute;
  color: #1877f2;
}

.risk-info p {
  margin: 5px 0;
  font-size: 14px;
}

.risk-glow {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 8px #1877f2;
  z-index: 0;
  opacity: 0.4;
}

.section-output {
  flex: 1;
  display: none;
}

.section-output.visible {
  display: block;
}

.chart-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}

.chart-container canvas {
  border-radius: 50%;
  background: #1f1f1f;
  padding: 6px;
  box-shadow:
    inset 4px 4px 8px rgba(0, 0, 0, 0.4),
    inset -4px -4px 8px rgba(255, 255, 255, 0.05);
}

body.light .chart-container canvas {
  background: #e6e6e6;
  box-shadow:
    inset 6px 6px 12px #c5c5c5,
    inset -6px -6px 12px #ffffff;
}

body.dark .chart-container canvas {
  background: #1f1f1f;
  box-shadow:
    inset 4px 4px 8px rgba(0, 0, 0, 0.4),
    inset -4px -4px 8px rgba(255, 255, 255, 0.05);
}

.card-header {
  position: absolute;
  height: 5px;
  top: 1px;
  right: 12px;
  z-index: 2;
}

.query {
  margin: 20px 0 2px 0;
  font-weight: 600;
  color: var(--blue);
}

.response {
  margin-top: 2px;
  max-width: 100%; /* Ensure response content doesn't exceed card width */
  overflow-x: auto; /* Allow horizontal scrolling for wide content */
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 22px;
  top: 0;
  transition: color 0.2s ease;
}
.copy-btn:hover {
  color: #1645ff;
}

.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  font-size: 22px;
}

.risk-text.low {
  color: #00cc66;
  font-weight: 600;
}
.risk-text.medium {
  color: #ffaa00;
  font-weight: 600;
}
.risk-text.high {
  color: #ff6600;
  font-weight: 600;
}
.risk-text.extreme {
  color: #ff0033;
  font-weight: 700;
}

.section-tag,
.section-num,
.punish-num,
.advice-num,
.case-num {
  background: #e0f7ff;
  padding: 1px 6px;
  border-radius: 12px;
  font-weight: 500;
  color: #006688;
  font-size: 13px;
  margin: 0 2px;
}

.party-text {
  color: #888;
  font-style: italic;
}

.dismiss-label {
  font-weight: bold;
  color: #999;
  margin-right: 4px;
}

.response b,
.doc-editor b,
.risk-details b {
  font-weight: bold;
}
.response i,
.doc-editor i,
.risk-details i {
  font-style: italic;
}
.response a,
.doc-editor a,
.risk-details a {
  color: #1877f2;
  text-decoration: underline;
}
.response a:hover,
.doc-editor a:hover,
.risk-details a:hover {
  color: #0f5cc2;
}
.response code,
.doc-editor code,
.risk-details code {
  background: #e0e0e0;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}
.response s,
.doc-editor s,
.risk-details s {
  text-decoration: line-through;
}
body.dark .response code,
.body.dark .doc-editor code,
.body.dark .risk-details code {
  background: #333;
}

#queryInput::placeholder {
  font-style: italic;
  color: #aaa;
}

#queryInput {
  font-style: normal !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Ensure wide content stays within response card */
.response table,
.response pre,
.response code,
.response .math-display,
.response .math-inline {
  max-width: 100%;
  word-break: break-word; /* Break long words to fit */
}

/* Tighten table spacing */
.response table {
  border-collapse: collapse;
  margin: 0; /* Remove any margin to avoid extra space */
  width: 100%;
}
.response th,
.response td {
  border: 1px solid #ccc;
  padding: 4px; /* Reduced from 8px */
  text-align: left;
  word-break: break-word; /* Prevent overflow from long cell content */
}
.response th {
  background: #f0f0f0;
  font-weight: bold;
}
body.dark .response th {
  background: #444;
}

.section-output:empty::before {
  content: "Hello";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  opacity: 0.15;
  pointer-events: none;
  width: 50vw; /* Cover 50% of screen width */
  text-align: center;
}

.section-output:empty::after {
  content: ",";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateX(70px); /* Adjust to position comma after "Hello" */
  font-size: 48px;
  font-weight: bold;
  opacity: 0.15;
  pointer-events: none;
  color: #1877f2; /* Facebook blue */
  animation: blink-comma 1s infinite;
  width: 50vw; /* Cover 50% of screen width */
  text-align: center;
}

body.light .section-output:empty::before {
  color: #333;
  text-shadow: 
    2px 2px 4px var(--shadow-light),
    -2px -2px 4px var(--shadow-dark);
}

body.dark .section-output:empty::before {
  color: #f2f2f2;
  text-shadow: 
    2px 2px 4px var(--shadow-dark),
    -2px -2px 4px var(--shadow-light);
}

body.light .section-output:empty::after,
body.dark .section-output:empty::after {
  color: #1877f2; /* Facebook blue in both modes */
  text-shadow: none; /* No engraved effect for comma */
}

.placeholder-input {
  border: none;
  outline: none;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--btn-bg);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  color: inherit;
  font-size: 14px;
  max-width: 100%;
  box-sizing: border-box;
  margin: 2px;
}

.placeholder-input::placeholder {
  color: #aaa;
  font-style: italic;
}

/* ✅ Prevent blue tap highlight on mobile */
* {
  -webkit-tap-highlight-color: transparent;
}

.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: auto; /* Allow dynamic height */
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: inherit;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  z-index: 999;
  box-sizing: border-box;
}

.footer .input-wrapper {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 600px; /* Limit width for smaller screens */
  justify-content: center;
  flex-wrap: wrap; /* Allow wrapping on small screens */
}

.disclaimer-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
}

.disclaimer-text {
  display: block;
  text-align: center;
  font-size: 12px;
  font-style: italic;
  opacity: 0.6;
  margin-top: 2px;
  margin-bottom: 2px;
  color: inherit;
}
@keyframes blink-comma {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@media (max-width: 600px) {
  .footer {
    padding-bottom: 20px; /* Extra space for disclaimer */
  }
  .disclaimer-text {
    line-height: 1.2; /* Adjust line height for better readability */
  }
}