/* Self-hosted Noto Sans Myanmar subset (Myanmar Unicode block only for fast mobile load) */
@font-face {
  font-family: "Noto Sans Myanmar Local";
  src: url("fonts/NotoSansMyanmar-Regular-subset.woff") format("woff");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+1000-109F, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Noto Sans Myanmar Local";
  src: url("fonts/NotoSansMyanmar-Bold-subset.woff") format("woff");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+1000-109F, U+200C-200D, U+25CC;
}

:root {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-deep: #131D31;
  --border: #334155;
  --border-subtle: rgba(148, 163, 184, 0.14);

  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;

  --emerald: #10B981;
  --emerald-soft: #34D399;
  --emerald-bg: rgba(16, 185, 129, 0.14);
  --emerald-border: rgba(16, 185, 129, 0.38);

  --coral: #EF4444;
  --coral-soft: #F87171;
  --coral-bg: rgba(239, 68, 68, 0.14);
  --coral-border: rgba(239, 68, 68, 0.38);

  --amber: #F59E0B;
  --amber-soft: #FBBF24;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --amber-border: rgba(245, 158, 11, 0.38);

  --accent-blue: #38BDF8;
  --radius-card: 16px;
  --radius-control: 11px;
  --radius-pill: 999px;

  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans Myanmar Local", "Myanmar MN", "Myanmar Sangam MN", "Pyidaungsu",
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-stack);
  background: radial-gradient(circle at 50% -8%, rgba(56, 189, 248, 0.09), transparent 46%),
    var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Compact Header */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.app-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.author-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.author-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.7);
}

.app-subtitle {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Shared Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.34);
}

/* Compact 4-Input Card */
.inputs-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inputs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.inputs-badge {
  font-size: 0.74rem;
  font-weight: 700;
  color: #7DD3FC;
  letter-spacing: 0.01em;
}

.pot-chip {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-deep);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  cursor: pointer;
}

.label-my {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.label-en {
  font-size: 0.71rem;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-inline-tag {
  font-weight: 700;
}

.slot-inline-tag.is-early {
  color: var(--emerald-soft);
}

.slot-inline-tag.is-mid {
  color: var(--amber-soft);
}

.slot-inline-tag.is-late {
  color: var(--coral-soft);
}

/* Unified +/- Stepper Control */
.stepper {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 40px;
  background: var(--surface-deep);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stepper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.stepper-btn {
  width: 36px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease;
}

.stepper-btn:hover {
  background: rgba(148, 163, 184, 0.12);
}

.stepper-btn:active {
  background: rgba(56, 189, 248, 0.2);
}

.stepper-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stepper-input {
  width: 58px;
  height: 100%;
  border: none;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  text-align: center;
  font-family: var(--font-stack);
  font-size: 0.96rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper-input-wide {
  width: 96px;
  font-size: 0.9rem;
}

.stepper-unit-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 100%;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: 0 4px;
}

.stepper-input-pct {
  width: 34px;
  border: none;
  text-align: right;
  padding: 0 1px 0 0;
}

.unit-symbol {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-left: 1px;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-input:focus {
  outline: none;
}

/* Results Card */
.results-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Good / Bad Verdict Banner */
.verdict-banner {
  border-radius: 13px;
  padding: 13px 15px;
  border: 1.5px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.verdict-banner.is-gain {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(16, 185, 129, 0.06));
  border-color: var(--emerald-border);
}

.verdict-banner.is-loss {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.06));
  border-color: var(--coral-border);
}

.verdict-banner.is-even {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.06));
  border-color: var(--amber-border);
}

.verdict-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.verdict-tag {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
}

.is-gain .verdict-tag {
  color: var(--emerald-soft);
}

.is-loss .verdict-tag {
  color: var(--coral-soft);
}

.is-even .verdict-tag {
  color: var(--amber-soft);
}

.verdict-pct {
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-secondary);
  white-space: nowrap;
}

.verdict-amount {
  margin-top: 3px;
  font-size: 1.72rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.is-gain .verdict-amount {
  color: var(--emerald);
}

.is-loss .verdict-amount {
  color: var(--coral);
}

.is-even .verdict-amount {
  color: var(--amber);
}

/* Waterfall Comparison Chart */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chart-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.chart-pot-ref {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-stage {
  background: var(--surface-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  padding: 8px 6px 6px;
}

.waterfall-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--font-stack);
  font-variant-numeric: tabular-nums;
}

/* Copy Button */
.copy-btn {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: linear-gradient(135deg, #0284C7, #0EA5E9);
  color: #F8FAFC;
  font-family: var(--font-stack);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 5px 14px rgba(2, 132, 199, 0.25);
  transition: transform 0.12s ease, filter 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.copy-btn:hover {
  filter: brightness(1.06);
}

.copy-btn:active {
  transform: scale(0.99);
}

.copy-btn.copied {
  background: linear-gradient(135deg, #059669, #10B981);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 5px 14px rgba(16, 185, 129, 0.25);
}

.copy-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Compact Footer */
.app-footer {
  text-align: center;
  padding: 2px 6px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.disclaimer {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.social-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
}

.social-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 7px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.social-link:hover {
  color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.1);
}

.social-sep {
  color: #475569;
}

@media (max-width: 375px) {
  .app-shell {
    padding: 12px 10px 20px;
  }

  .card {
    padding: 12px;
  }

  .stepper-btn {
    width: 32px;
  }

  .stepper-input {
    width: 50px;
  }

  .stepper-input-wide {
    width: 84px;
    font-size: 0.84rem;
  }

  .verdict-amount {
    font-size: 1.54rem;
  }
}
