/* Tip Calculator plugin styles — everything scoped under .tipcalc so it never
   leaks into the surrounding theme. No :root, no bare tag selectors, no body rules. */

.tipcalc{
  --tc-counter-1: #1C1712;
  --tc-counter-2: #0E0B08;
  --tc-paper: #FBF8F1;
  --tc-paper-well: #F2EDE0;
  --tc-ink: #24241E;
  --tc-ink-soft: #726A59;
  --tc-stamp: #A23B2E;
  --tc-stamp-ink: #FBF3EC;
  --tc-rule: #D9D0BC;
  --tc-rule-strong: #B9AF97;

  display: flex;
  justify-content: center;
  box-sizing: border-box;
  padding: clamp(20px, 5vw, 40px) 14px;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 700px 420px at 50% -15%, rgba(255,232,200,.08), transparent 60%),
    radial-gradient(ellipse 900px 600px at 50% 115%, var(--tc-counter-2), var(--tc-counter-1));
  font-family: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  line-height: 1.35;
}
@media (prefers-color-scheme: dark){
  .tipcalc:not([data-theme="light"]){
    --tc-counter-1: #100D0A;
    --tc-counter-2: #050403;
    --tc-paper: #EFEADB;
    --tc-paper-well: #E6DFCC;
    --tc-ink: #1E1B15;
    --tc-ink-soft: #6C6455;
    --tc-stamp: #B8483A;
    --tc-rule: #CEC3A9;
    --tc-rule-strong: #ADA083;
  }
}
.tipcalc[data-theme="dark"]{
  --tc-counter-1: #100D0A;
  --tc-counter-2: #050403;
  --tc-paper: #EFEADB;
  --tc-paper-well: #E6DFCC;
  --tc-ink: #1E1B15;
  --tc-ink-soft: #6C6455;
  --tc-stamp: #B8483A;
  --tc-rule: #CEC3A9;
  --tc-rule-strong: #ADA083;
}

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

.tc-stage{ width: 100%; max-width: 430px; }

.tc-receipt{
  position: relative;
  background: var(--tc-paper);
  color: var(--tc-ink);
  clip-path: polygon(
    0% 0px, 8.33% 6px, 16.67% 0px, 25% 6px, 33.33% 0px, 41.67% 6px, 50% 0px,
    58.33% 6px, 66.67% 0px, 75% 6px, 83.33% 0px, 91.67% 6px, 100% 0px,
    100% 100%, 91.67% calc(100% - 6px), 83.33% 100%, 75% calc(100% - 6px),
    66.67% 100%, 58.33% calc(100% - 6px), 50% 100%, 41.67% calc(100% - 6px),
    33.33% 100%, 25% calc(100% - 6px), 16.67% 100%, 8.33% calc(100% - 6px), 0% 100%
  );
  filter: drop-shadow(0 24px 34px rgba(0,0,0,.42)) drop-shadow(0 2px 0 rgba(0,0,0,.15));
  opacity: 1;
}
@media (prefers-reduced-motion: no-preference){
  .tc-receipt{ animation: tipcalcPrintUp .55s cubic-bezier(.2,.7,.3,1) both; }
}
@keyframes tipcalcPrintUp{
  from{ opacity: 0; transform: translateY(26px); }
  to{ opacity: 1; transform: translateY(0); }
}

.tc-receipt-inner{ padding: 34px 26px 28px; }

.tc-masthead{ text-align: center; margin-bottom: 18px; }
.tc-masthead h3{
  font-family: "Fraunces", "Iowan Old Style", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(24px, 6vw, 28px);
  line-height: 1.1;
  letter-spacing: .01em;
  margin: 0 0 8px;
}
.tc-stamp-line{
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 11px; letter-spacing: .09em; color: var(--tc-ink-soft);
}
.tc-stamp-line::before, .tc-stamp-line::after{
  content: ""; height: 1px; width: 26px; background: var(--tc-rule-strong);
}

.tc-rule{ border: none; border-top: 1px dashed var(--tc-rule); margin: 18px 0; }
.tc-rule.tc-strong{ border-top: 2px dashed var(--tc-rule-strong); }

.tipcalc fieldset{ border: none; margin: 0; padding: 0; }
.tipcalc legend{
  font-size: 11px; letter-spacing: .08em; color: var(--tc-ink-soft);
  margin-bottom: 10px; padding: 0;
}

.tc-field-row{
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.tc-field-row:last-child{ margin-bottom: 0; }
.tc-field-row label{ font-size: 13.5px; color: var(--tc-ink); }
.tc-amount-input{ display: flex; align-items: baseline; gap: 3px; }
.tc-amount-input span{ color: var(--tc-ink-soft); font-size: 14px; }

.tipcalc input[type="number"]{
  font-family: inherit; font-size: 16px; font-weight: 500; color: var(--tc-ink);
  background: transparent; border: none; border-bottom: 1px solid var(--tc-rule-strong);
  text-align: right; width: 8ch; padding: 2px 2px 4px; font-variant-numeric: tabular-nums;
}
.tipcalc input[type="number"]::-webkit-inner-spin-button,
.tipcalc input[type="number"]::-webkit-outer-spin-button{ -webkit-appearance: none; margin: 0; }
.tipcalc input[type="number"]{ -moz-appearance: textfield; appearance: textfield; }
.tipcalc input[type="number"]:focus{ border-bottom-color: var(--tc-ink); }
.tipcalc input:focus-visible,
.tipcalc button:focus-visible{ outline: 2px solid var(--tc-ink); outline-offset: 2px; }

.tc-presets{ display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tc-chip{
  font-family: inherit; font-size: 14px; font-weight: 500; color: var(--tc-ink);
  background: var(--tc-paper-well); border: 1px solid var(--tc-rule-strong); border-radius: 3px;
  padding: 7px 12px; cursor: pointer;
  transition: transform .08s ease, background .12s ease, color .12s ease, border-color .12s ease;
}
.tc-chip:active{ transform: scale(.95); }
.tc-chip[aria-pressed="true"]{ background: var(--tc-stamp); border-color: var(--tc-stamp); color: var(--tc-stamp-ink); }

.tc-custom-tip{ display: flex; align-items: center; gap: 10px; }
.tc-custom-tip label{ font-size: 13px; color: var(--tc-ink-soft); flex-shrink: 0; }
.tipcalc input[type="range"]{ flex: 1 1 auto; accent-color: var(--tc-stamp); height: 20px; }
.tc-custom-tip .tc-amount-input{ flex-shrink: 0; }
.tc-custom-tip input[type="number"]{ width: 5ch; }

.tc-radio-option, .tc-check-option{
  display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; line-height: 1.4;
  margin-bottom: 10px; cursor: pointer;
}
.tc-radio-option:last-child, .tc-check-option:last-child{ margin-bottom: 0; }
.tipcalc input[type="radio"], .tipcalc input[type="checkbox"]{
  accent-color: var(--tc-stamp); width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; cursor: pointer;
}
.tc-hint{ display: block; color: var(--tc-ink-soft); font-size: 11.5px; margin-top: 1px; }

.tc-stepper{ display: flex; align-items: center; gap: 14px; }
.tc-stepper button{
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--tc-rule-strong);
  background: var(--tc-paper-well); color: var(--tc-ink); font-size: 16px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .08s ease;
}
.tc-stepper button:active{ transform: scale(.92); }
.tc-stepper output{ font-size: 16px; font-weight: 600; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

.tc-line{ display: flex; align-items: flex-end; gap: 6px; margin-bottom: 9px; font-size: 13.5px; }
.tc-line .tc-label{ color: var(--tc-ink-soft); white-space: nowrap; }
.tc-line .tc-leader{ flex: 1 1 auto; border-bottom: 1px dotted var(--tc-rule); height: 0; margin-bottom: 3px; }
.tc-line .tc-value{ font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }

.tc-totals{ margin-top: 4px; }
.tc-total-row{ display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 4px; }
.tc-total-row .tc-label{ font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 17px; }
.tc-total-row .tc-value{
  font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: transform .18s ease, color .18s ease;
}
.tc-total-row .tc-value.tc-pulse{ transform: scale(1.06); color: var(--tc-stamp); }

.tc-each-pays{
  background: var(--tc-paper-well); border: 1px dashed var(--tc-rule-strong); border-radius: 4px;
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px;
}
.tc-each-pays .tc-label{ font-size: 12.5px; color: var(--tc-ink-soft); letter-spacing: .04em; }
.tc-each-pays .tc-value{
  font-size: 22px; font-weight: 600; color: var(--tc-stamp); font-variant-numeric: tabular-nums;
  transition: transform .18s ease;
}
.tc-each-pays .tc-value.tc-pulse{ transform: scale(1.06); }
.tc-rounding-note{ font-size: 11px; color: var(--tc-ink-soft); margin-top: 8px; font-style: italic; min-height: 14px; }

.tc-actions{ display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.tc-actions button{
  flex: 1 1 auto; font-family: inherit; font-size: 12.5px; font-weight: 500; letter-spacing: .02em;
  padding: 10px 10px; border-radius: 3px; cursor: pointer; border: 1px solid var(--tc-ink);
  background: transparent; color: var(--tc-ink);
  transition: transform .08s ease, background .12s ease, color .12s ease; white-space: nowrap;
}
.tc-actions button:active{ transform: scale(.97); }
.tc-actions button.tc-primary{ background: var(--tc-ink); color: var(--tc-paper); }

.tc-fine-print{ margin-top: 22px; font-size: 10.5px; line-height: 1.5; color: var(--tc-ink-soft); text-align: center; }
.tc-fine-print .tc-formula{ display: block; margin-top: 6px; letter-spacing: .02em; }

.tc-toast{
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 12px);
  background: var(--tc-ink); color: var(--tc-paper); font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px; padding: 9px 16px; border-radius: 4px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 9999;
}
.tc-toast.tc-show{ opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px){
  .tc-receipt-inner{ padding: 30px 18px 24px; }
}

@media print{
  .tipcalc{ background: none; padding: 0; }
  .tc-receipt{ clip-path: none; filter: none; }
  .tc-actions, .tc-toast{ display: none !important; }
}
