:root {
  /* White Theme (Light) */
  --bg-color: #ffffff;
  /* Pure white background */
  --card-bg: #f8f9fa;
  /* Very subtle grey for card/contrast */
  --text-primary: #111827;
  /* Near black text */
  --text-secondary: #6b7280;
  /* Grey text */
  --accent-color: #111827;
  /* Dark accent */
  --accent-text: #ffffff;
  /* Text on accent */
  --border-color: #e5e7eb;
  /* Light grey border */
  --input-bg: #ffffff;
  /* White inputs */
  --input-border: #d1d5db;
  /* Visible border for inputs */
  --highlight-color: #10b981;
  --font-family: 'Inter', sans-serif;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --header-height: 60px;
  --radius-lg: 32px;
  --radius-md: 16px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-color: #09090b;
  /* Very dark background */
  --card-bg: #18181b;
  /* Dark card */
  --text-primary: #f9fafb;
  /* White text */
  --text-secondary: #9ca3af;
  /* Light grey text */
  --accent-color: #f9fafb;
  /* White accent */
  --accent-text: #000000;
  /* Black text on white accent */
  --border-color: #27272a;
  /* Dark border */
  --input-bg: #27272a;
  /* Dark input bg */
  --input-border: #3f3f46;
  /* Dark input border */
  --highlight-color: #4ade80;
  --shadow: none;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, color 0.1s ease, border-color 0.1s ease;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-bottom: 40px;
}

.app-container {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header */
.app-header {
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-color);
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  font-size: 1.1rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background-color: var(--border-color);
}

/* Main Card */
.calculator-card {
  padding: 10px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Input Group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-left: 4px;
}

/* Currency & Bill Input */
.input-wrapper {
  display: flex;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  align-items: center;
  border: 1px solid var(--input-border);
}

.input-wrapper:focus-within {
  border-color: var(--text-primary);
}

.currency-input select {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  padding-right: 8px;
  cursor: pointer;
}

.currency-input select option {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

.currency-input input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  text-align: right;
  width: 100%;
}

.currency-input input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Custom Tip Only */
/* Clean Tip Input inside wrapper */
.custom-tip-wrapper-clean {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.custom-tip-wrapper-clean input {
  width: 60%;
  background: transparent;
  border: none;
  text-align: right;
  /* Align right to sit next to % */
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  padding: 0;
}

.custom-tip-wrapper-clean .percent-symbol-clean {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-left: 2px;
}

.full-width-custom {
  width: 100%;
}

.custom-tip-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.custom-tip-wrapper input {
  width: 100%;
  height: 50px;
  background: var(--card-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 600;
  outline: none;
  padding: 0 40px;
}

.custom-tip-wrapper input:focus {
  border-color: var(--text-primary);
  background: var(--bg-color);
}

.percent-symbol {
  position: absolute;
  right: 20px;
  font-size: 1.2rem;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Split Section */
.split-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.split-toggles {
  display: flex;
  background: var(--input-bg);
  padding: 4px;
  border-radius: 50px;
  gap: 2px;
}

.split-mode-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.split-mode-btn.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.people-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-top: 10px;
}

.icon-btn {
  background: var(--border-color);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--border-color);
}

.people-count #numberOfPeople {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.people-count .label-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Custom Split Inputs */
.custom-split-container {
  margin-top: 16px;
}

.custom-split-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.custom-split-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.custom-split-input span {
  font-size: 0.95rem;
  font-weight: 600;
}

.custom-split-input input {
  width: 100px;
  padding: 8px;
  border: none;
  background: var(--input-bg);
  border-radius: 8px;
  text-align: right;
  color: var(--text-primary);
  outline: none;
  font-weight: 700;
}

.people-control-mini {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 16px;
}

.text-btn {
  background: var(--border-color);
  border: none;
  padding: 8px 16px;
  border-radius: 50px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* Options */
.options-row {
  display: flex;
  justify-content: flex-end;
  padding: 0 4px;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--card-bg);
  padding: 8px 16px;
  border-radius: 50px;
  box-shadow: var(--shadow);
}

.checkbox-wrapper label {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
  accent-color: var(--accent-color);
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Results Card */
.results-card {
  background: var(--accent-color);
  color: var(--accent-text);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 10px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}



[data-theme="dark"] .results-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.result-row span:first-child {
  opacity: 0.7;
  font-size: 0.95rem;
  font-weight: 500;
}

.result-row .value {
  font-weight: 600;
  font-size: 1.25rem;
}

.divider {
  height: 2px;
  background: currentColor;
  opacity: 0.1;
  margin: 20px 0;
  border-radius: 2px;
}

.result-row.total .value {
  font-size: 1.5rem;
  font-weight: 800;
}

.result-row.per-person {
  margin-bottom: 0;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.15);
  padding: 16px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .result-row.per-person {
  background: var(--input-bg);
}

.result-row.per-person .value {
  color: var(--highlight-color);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

/* Footer */
.app-footer {
  padding: 24px;
  text-align: center;
}

.app-footer p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.app-footer a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
}

/* Responsive constraints */
@media (min-width: 481px) {
  .app-container {
    max-width: 420px;
    min-height: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.15);
    margin-top: 40px;
    border: 1px solid var(--border-color);
  }

  .app-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}