/* =========================================================
   SMS Cost Calculator — standalone, scoped under #sms-calc-app
   Visual language matches the SFMC multiplier tracker.
   ========================================================= */

html, body { background: #d0d5de; margin: 0; padding: 0; }
*, *::before, *::after { box-sizing: border-box; }

#sms-calc-app {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: #1a2744;
  background: #d0d5de;
  padding: 20px;
  min-height: 100vh;
  --offset: 20px;
  --bar: 50px;
  --navy:        #0d1b3e;
  --navy-mid:    #1a3a6b;
  --surface:     #ffffff;
  --surface-2:   #f7f8fa;
  --surface-3:   #fafbfc;
  --border:      #d4d8e1;
  --border-2:    #e2e5ec;
  --text:        #1a2744;
  --text-2:      #4b5563;
  --text-3:      #8896aa;
  --amber:       #d97706;
  --green:       #059669;
  --red:         #b91c1c;
  --teal:        #0a3a5c;
  --teal-light:  #d8e8f4;
  --rad-sm:      4px;
  --rad-md:      6px;
  --rad-lg:      10px;
}
#sms-calc-app .panel {
  max-width: 1400px;
  margin: 0 auto;
  border-radius: var(--rad-lg);
  overflow: clip;
  box-shadow: 0 8px 44px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
  background: #ebebeb;
}

/* ── Top bar ── */
#sms-calc-app .top {
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--offset);
  z-index: 100;
  min-height: var(--bar);
}
#sms-calc-app .top h1 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  letter-spacing: .01em;
  margin: 0;
}
#sms-calc-app .top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#sms-calc-app .shared-name {
  background: #1a2f5c;
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--rad-sm);
  font-size: 13px;
  font-weight: 600;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sms-calc-app .top-input {
  background: #1a2f5c;
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--rad-sm);
  padding: 5px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 230px;
  outline: none;
}
#sms-calc-app .top-input::placeholder { color: rgba(255,255,255,.45); }
#sms-calc-app .top-input:focus { border-color: rgba(255,255,255,.5); background: #233a6e; }
#sms-calc-app .btn {
  border: none;
  border-radius: var(--rad-sm);
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-weight: 600;
  transition: opacity .15s, background .15s, color .15s;
  font-family: inherit;
  height: 30px;
  line-height: 1;
}
#sms-calc-app .btn:hover { opacity: .85; }
#sms-calc-app .btn-share { background: #fff; color: var(--navy); }
#sms-calc-app .btn-save,
#sms-calc-app .btn-import { background: #1a2f5c; color: #fff; border: 1px solid rgba(255,255,255,.18); }
#sms-calc-app .btn-save:hover,
#sms-calc-app .btn-import:hover { background: #233a6e; opacity: 1; }

/* ── Layout: two columns, independent scroll ── */
#sms-calc-app .layout {
  display: flex;
  height: calc(100vh - var(--offset)*2 - var(--bar));
  min-height: 600px;
  background: var(--surface-2);
}
#sms-calc-app .left-col {
  width: 540px;
  min-width: 380px;
  max-width: 60%;
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
#sms-calc-app .right-col {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface-2);
  min-width: 0;
  position: relative;
}
#sms-calc-app .left-pad  { padding: 16px 18px 24px; }
#sms-calc-app .right-pad { padding: 16px 18px 24px; }

/* ── Section divider ── */
#sms-calc-app .sec-divider {
  border: none;
  border-top: 1px solid var(--border-2);
  margin: 22px 0 18px;
}

/* ── Tabs ── */
#sms-calc-app .tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
}
#sms-calc-app .tab {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--rad-md) var(--rad-md) 0 0;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 10px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: -1px;
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
#sms-calc-app .tab:hover:not(.is-active) { background: #eef0f4; }
#sms-calc-app .tab.is-active {
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  z-index: 2;
  box-shadow: 0 -1px 3px rgba(15,31,61,.05);
}
#sms-calc-app .tab-title { font-size: 12px; font-weight: 700; color: var(--text-3); }
#sms-calc-app .tab.is-active .tab-title { color: var(--navy); }
#sms-calc-app .tab-desc  { font-size: 10.5px; color: var(--text-3); }
#sms-calc-app .tab.is-active .tab-desc { color: var(--text-2); }

/* ── Textarea ── */
#sms-calc-app .input-wrap { margin: 0; }
#sms-calc-app .textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 200px;
  padding: 11px 12px;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--navy);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--rad-md) var(--rad-md);
  border-top: none;
  /* Height is driven by JS auto-grow — the textarea expands to fit its
     content so it never shows an internal scrollbar. The left column
     scrolls instead. */
  resize: none;
  overflow-y: hidden;
  outline: none;
  box-shadow: 0 1px 4px rgba(15,31,61,.06);
  transition: border-color .15s, box-shadow .15s;
}
#sms-calc-app .textarea:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 1px 6px rgba(26,58,107,.14);
}

#sms-calc-app .meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
}
#sms-calc-app .draft-status { font-style: italic; flex: 1; text-align: center; }
/* ─── Optimize controls (shared pill design) ───
   Both the "auto" toggle and the manual button live in the meta row and
   share padding, height, border-radius and typography so they read as a
   pair. They visually shift between an "off"/grey state and an "on"/green
   state to reinforce the same on/off semantics. */

#sms-calc-app .gsm7-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  border-radius: var(--rad-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
#sms-calc-app .gsm7-pill:hover:not(:disabled):not(.is-active) {
  background: var(--surface-2);
  border-color: #b0b4be;
  color: var(--navy);
}

/* Active/on state — neutral grey "pressed" look. The green checkbox tick
   carries the on/off signal; the pill itself stays calm. */
#sms-calc-app .gsm7-pill.is-active,
#sms-calc-app .gsm7-pill.is-active:hover {
  background: var(--surface-2);
  border-color: #b0b4be;
  color: var(--navy);
}

/* Disabled (manual button only — when no chars to optimize) */
#sms-calc-app .gsm7-pill:disabled {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-3);
  cursor: not-allowed;
  opacity: .7;
}

/* Hide the manual button entirely while auto-optimize is on */
#sms-calc-app .gsm7-pill.is-hidden { display: none; }

/* Native checkbox inside the auto-toggle pill */
#sms-calc-app .gsm7-pill input[type="checkbox"] {
  accent-color: #059669;
  cursor: pointer;
  width: 12px;
  height: 12px;
  margin: 0;
  flex-shrink: 0;
}

/* Small numeric badge for the manual button's pending-count */
#sms-calc-app .gsm7-pill .gsm7-count {
  background: #059669;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  padding: 0 5px;
  min-width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#sms-calc-app .gsm7-pill:disabled .gsm7-count { background: var(--text-3); }

/* Toast (unchanged behaviour, slimmer styling to match pills) */
#sms-calc-app .optimize-toast {
  display: none;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--rad-sm);
  padding: 4px 9px;
  margin-top: 6px;
}
#sms-calc-app .optimize-toast.is-visible { display: inline-block; }

/* ── Stats grid ── */
#sms-calc-app .stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 18px 0 4px;
}
#sms-calc-app .stat-card {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--rad-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color .15s, box-shadow .15s;
}
#sms-calc-app .stat-card:hover { border-color: var(--border); box-shadow: 0 2px 6px rgba(15,31,61,.06); }
#sms-calc-app .stat-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
#sms-calc-app .stat-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  line-height: 1.1;
}
/* SMS-parts count gets a green→red gradient so the cost implication
   of going from 1 to 4 parts is visible at a glance. Capped at 4+. */
#sms-calc-app .stat-value--parts-1 { color: #059669; }   /* green */
#sms-calc-app .stat-value--parts-2 { color: #d97706; }   /* amber */
#sms-calc-app .stat-value--parts-3 { color: #dc2626; }   /* orange-red */
#sms-calc-app .stat-value--parts-4 { color: #991b1b; }   /* red */
#sms-calc-app .stat-sub {
  font-size: 10.5px;
  color: var(--text-3);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

/* ── Personalisation panel ── */
#sms-calc-app .pers-panel {
  margin-top: 12px;
  padding: 12px 13px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-md);
  box-shadow: 0 1px 4px rgba(15,31,61,.06);
}
#sms-calc-app .pers-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
#sms-calc-app .pers-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
#sms-calc-app .pers-hint {
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
#sms-calc-app .pers-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
#sms-calc-app .pers-list:empty { margin-bottom: 0; }

#sms-calc-app .sms-calc__pers-var {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--rad-md);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
#sms-calc-app .sms-calc__pers-var:focus-within { border-color: var(--border); box-shadow: 0 2px 6px rgba(15,31,61,.06); }

#sms-calc-app .sms-calc__pers-var-row1,
#sms-calc-app .sms-calc__pers-var-row2 {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: flex-end;
}
#sms-calc-app .sms-calc__pers-var-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
#sms-calc-app .sms-calc__pers-var-field--wide { flex: 2; }
#sms-calc-app .sms-calc__pers-var-field-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}
#sms-calc-app .sms-calc__pers-var-field-optional {
  font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text-3);
}
#sms-calc-app .sms-calc__pers-var-name,
#sms-calc-app .sms-calc__pers-var-type,
#sms-calc-app .sms-calc__pers-var input[type="text"],
#sms-calc-app .sms-calc__pers-var input[type="number"] {
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  color: var(--navy);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-sm);
  outline: none;
  width: 100%;
  font-family: inherit;
}
#sms-calc-app .sms-calc__pers-var-name { font-weight: 600; }
#sms-calc-app .sms-calc__pers-var-name:focus,
#sms-calc-app .sms-calc__pers-var-type:focus,
#sms-calc-app .sms-calc__pers-var input:focus { border-color: var(--navy-mid); }

#sms-calc-app .sms-calc__pers-var-actions { display: flex; gap: 5px; align-items: flex-end; flex-shrink: 0; }
#sms-calc-app .sms-calc__pers-var-insert {
  height: 30px; padding: 0 9px; font-size: 11.5px; font-weight: 700;
  color: var(--teal); background: var(--teal-light); border: 1px solid #a8c8e0;
  border-radius: var(--rad-sm); cursor: pointer; white-space: nowrap; font-family: inherit;
}
#sms-calc-app .sms-calc__pers-var-insert:hover:not(:disabled) { background: #bdd8ee; }
#sms-calc-app .sms-calc__pers-var-insert:disabled { opacity: .35; cursor: not-allowed; }
#sms-calc-app .sms-calc__pers-var-remove {
  background: none; border: 1px solid var(--border); border-radius: var(--rad-sm);
  width: 30px; height: 30px; font-size: 16px; line-height: 1; color: var(--text-3); cursor: pointer; font-family: inherit;
}
#sms-calc-app .sms-calc__pers-var-remove:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

#sms-calc-app .sms-calc__pers-var-token-row {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--rad-sm);
  flex-wrap: wrap;
}
#sms-calc-app .sms-calc__pers-var-token-row--empty { background: var(--surface-2); border-color: var(--border-2); }
#sms-calc-app .sms-calc__pers-var-token-label { font-size: 10.5px; color: var(--text-3); }
#sms-calc-app .sms-calc__pers-var-token {
  font-family: 'SFMono-Regular','Consolas',monospace;
  font-size: 12px; font-weight: 700; color: var(--teal); background: var(--teal-light);
  padding: 1px 7px; border-radius: 3px;
}
#sms-calc-app .sms-calc__pers-var-length { font-size: 10.5px; color: var(--text-3); margin-left: auto; }

#sms-calc-app .sms-calc__pers-var-length-group {
  padding: 7px 9px; background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: var(--rad-sm);
}
#sms-calc-app .sms-calc__pers-var-length-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
#sms-calc-app .sms-calc__pers-var-length-group-title {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
}
#sms-calc-app .sms-calc__pers-var-sample {
  font-size: 10.5px; color: var(--text-3);
}
#sms-calc-app .sms-calc__pers-var-sample code {
  font-family: 'SFMono-Regular','Consolas',monospace;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 3px; padding: 1px 5px; color: var(--text-2);
}
#sms-calc-app .sms-calc__pers-var-format-hint {
  font-size: 10.5px; color: var(--text-3); align-self: flex-end; padding-bottom: 4px; font-style: italic;
}

#sms-calc-app .pers-add-btn {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--rad-sm);
  padding: 7px 10px; font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; width: 100%; text-align: center; font-family: inherit;
}
#sms-calc-app .pers-add-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--navy); }
#sms-calc-app .pers-add-btn:disabled { opacity: .45; cursor: not-allowed; }

#sms-calc-app .pers-encoding-warning { margin-top: 8px; }

/* ── Cost section ── */
#sms-calc-app .cost-section { margin-top: 4px; }
#sms-calc-app .cost-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
#sms-calc-app .cost-title {
  font-size: 13px; font-weight: 700; color: var(--navy); margin: 0;
  display: flex; align-items: center; gap: 6px;
}
#sms-calc-app .badge {
  font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 3px; padding: 1px 6px;
}
#sms-calc-app .save-toast {
  display: none; font-size: 12.5px; color: #065f46; background: #d1fae5;
  border: 1px solid #a7f3d0; border-radius: var(--rad-sm); padding: 7px 10px; margin-bottom: 10px;
}
#sms-calc-app .save-toast.is-visible { display: block; }
#sms-calc-app .mismatch-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: #78350f; background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: var(--rad-sm); padding: 7px 10px; margin-bottom: 10px;
}
#sms-calc-app .mismatch-body { display: flex; gap: 6px; align-items: flex-start; }
#sms-calc-app .mismatch-load-btn {
  background: var(--surface); border: 1px solid #f59e0b; border-radius: 4px;
  padding: 4px 9px; font-size: 11.5px; font-weight: 600; color: #78350f; cursor: pointer; font-family: inherit;
}
#sms-calc-app .mismatch-load-btn:hover { background: #fde68a; }

#sms-calc-app .cost-cols {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
#sms-calc-app .cost-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-md);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
#sms-calc-app .cost-card:hover { box-shadow: 0 1px 4px rgba(15,31,61,.06); }
#sms-calc-app .cost-card[open] { box-shadow: 0 2px 8px rgba(15,31,61,.07); }
#sms-calc-app .cost-card > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-bottom: 1px solid transparent;
  font-family: inherit;
  transition: background .12s, border-color .12s;
}
#sms-calc-app .cost-card > summary::-webkit-details-marker { display: none; }
#sms-calc-app .cost-card > summary::marker { content: ''; }
#sms-calc-app .cost-card:hover > summary { background: #eef0f4; }
#sms-calc-app .cost-card[open] > summary {
  background: var(--surface);
  border-bottom-color: var(--border-2);
}
#sms-calc-app .cost-card-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  filter: grayscale(60%);
  opacity: .8;
}
#sms-calc-app .cost-card[open] .cost-card-icon { filter: grayscale(0); opacity: 1; }
#sms-calc-app .cost-card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .01em;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
#sms-calc-app .cost-card-summary {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  padding-right: 4px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}
#sms-calc-app .cost-card[open] .cost-card-summary { display: none; }
#sms-calc-app .cost-card-caret {
  font-size: 10px;
  color: var(--text-3);
  transition: transform .2s;
  flex-shrink: 0;
  display: inline-block;
}
#sms-calc-app .cost-card[open] .cost-card-caret { transform: rotate(90deg); }
#sms-calc-app .cost-card-body {
  padding: 13px 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
#sms-calc-app .badge--optional {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}
#sms-calc-app .field-group { display: flex; flex-direction: column; gap: 4px; }
#sms-calc-app .field-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
}
#sms-calc-app .field-optional { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text-3); }
#sms-calc-app .field-hint { font-size: 11px; color: var(--text-3); line-height: 1.4; min-height: 1em; }

#sms-calc-app .select,
#sms-calc-app .input-num,
#sms-calc-app .input-custom-currency {
  height: 32px; padding: 0 9px; font-size: 12.5px;
  color: var(--navy); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--rad-sm);
  outline: none; width: 100%; font-family: inherit;
  transition: border-color .15s;
}
#sms-calc-app .select:focus,
#sms-calc-app .input-num:focus,
#sms-calc-app .input-custom-currency:focus { border-color: var(--navy-mid); }
#sms-calc-app .select { cursor: pointer; }
#sms-calc-app .select--auto { width: auto; }
#sms-calc-app .input-num--tiny { width: 60px; flex-shrink: 0; }

#sms-calc-app .input-currency-wrap {
  display: flex; align-items: center; height: 32px;
  border: 1px solid var(--border); border-radius: var(--rad-sm); background: var(--surface);
  overflow: hidden; width: 100%;
}
#sms-calc-app .input-currency-wrap:focus-within { border-color: var(--navy-mid); }
#sms-calc-app .currency-symbol {
  padding: 0 6px 0 9px; font-size: 12.5px; color: var(--text-3);
  background: var(--surface-2); border-right: 1px solid var(--border-2);
  display: flex; align-items: center; align-self: stretch;
}
#sms-calc-app .input-currency-wrap .input-num { border: none; border-radius: 0; height: 100%; padding-left: 7px; }
#sms-calc-app .radio-group { display: flex; flex-direction: column; gap: 4px; }
#sms-calc-app .radio-label {
  font-size: 12.5px; color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; gap: 5px;
}
#sms-calc-app .radio-label input[type="radio"] { accent-color: var(--navy-mid); }
#sms-calc-app .schedule-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
#sms-calc-app .schedule-text { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* Estimates table */
#sms-calc-app .estimates-wrap { margin-top: 12px; }
#sms-calc-app .estimates-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 8px; display: flex; align-items: center; gap: 5px;
}
#sms-calc-app .estimates-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  border: 1px solid var(--border-2); border-radius: var(--rad-md); overflow: hidden;
}
#sms-calc-app .estimates-th {
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2);
  padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--border-2);
}
#sms-calc-app .estimates-th--metric { text-align: left; width: 42%; }
#sms-calc-app .estimates-th--cost { color: var(--navy); }
#sms-calc-app .estimates-row td {
  padding: 8px 10px; border-bottom: 1px solid var(--surface-2); vertical-align: middle;
}
#sms-calc-app .estimates-row:last-child td { border-bottom: none; }
#sms-calc-app .estimates-metric {
  font-size: 12px; color: var(--text-2); text-align: left;
  display: flex; align-items: center; gap: 5px;
}
#sms-calc-app .estimates-value {
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--navy); text-align: right;
}
#sms-calc-app .estimates-row--total td { background: var(--surface-2); }
#sms-calc-app .estimates-row--total .estimates-metric { color: var(--navy); font-weight: 700; }
#sms-calc-app .estimates-value--total { font-size: 17px; font-weight: 800; }
#sms-calc-app .estimates-subs { margin-top: 6px; }
#sms-calc-app .estimates-sub { font-size: 11px; color: var(--text-3); margin: 0; line-height: 1.5; }
#sms-calc-app .cost-note {
  font-size: 11px; color: var(--text-3); line-height: 1.5;
  padding: 6px 9px; background: var(--surface-2);
  border-radius: var(--rad-sm); border-left: 3px solid var(--border); margin-top: 8px;
}
#sms-calc-app .disclaimer {
  margin: 16px 0 0; padding: 9px 11px; font-size: 11px; line-height: 1.55;
  color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: var(--rad-sm); font-style: italic;
}

/* ════════════════════════════════════════════
   RIGHT COLUMN — Breakdown
   ════════════════════════════════════════════ */
#sms-calc-app .right-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
/* Hide the breakdown header until there's actually a breakdown to label. */
#sms-calc-app .right-header.is-hidden { display: none; }
/* Space the encoding notes from the breakdown header only when notes exist. */
#sms-calc-app #sms-calc-notes:not(:empty) { margin-bottom: 20px; }
#sms-calc-app .right-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 5px;
}
#sms-calc-app .legend { display: flex; gap: 5px; flex-wrap: wrap; }
#sms-calc-app .legend-item {
  font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
}
#sms-calc-app .legend-item--gsm     { background: #dcfce7; color: #166534; }
#sms-calc-app .legend-item--ext     { background: #fef9c3; color: #854d0e; }
#sms-calc-app .legend-item--unicode { background: #fee2e2; color: #991b1b; }

#sms-calc-app .breakdown-wrap { display: none; }
#sms-calc-app .breakdown-wrap.is-visible { display: block; }

#sms-calc-app .empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 200px; color: var(--text-3); gap: 8px; text-align: center; font-size: 13px;
  padding: 40px 20px;
}
#sms-calc-app .empty-state.is-hidden { display: none; }
#sms-calc-app .empty-state-icon { font-size: 28px; opacity: .35; }

#sms-calc-app .pers-variant { margin-bottom: 16px; }
#sms-calc-app .pers-variant:last-child { margin-bottom: 0; }
#sms-calc-app .pers-variant-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 7px; padding-bottom: 5px;
  border-bottom: 1px dashed var(--border-2);
}

/* Part row */
#sms-calc-app .sms-calc__part-row {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--rad-md); padding: 10px 12px; margin-bottom: 10px;
}
#sms-calc-app .sms-calc__part-row--sparse { border-color: #fcd34d; background: #fffbeb; }
#sms-calc-app .sms-calc__part-row-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
#sms-calc-app .sms-calc__part-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 3px; padding: 2px 7px; flex-shrink: 0;
}
#sms-calc-app .sms-calc__part-count {
  font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; flex-shrink: 0;
}
#sms-calc-app .sms-calc__part-bar-wrap {
  flex: 1; height: 4px; background: var(--border-2); border-radius: 2px; overflow: hidden;
}
#sms-calc-app .sms-calc__part-bar {
  height: 100%; background: var(--navy-mid); border-radius: 2px; min-width: 2px;
}
#sms-calc-app .sms-calc__part-row--sparse .sms-calc__part-bar { background: var(--amber); }

#sms-calc-app .sms-calc__char-grid {
  display: flex; flex-wrap: wrap; gap: 3px; line-height: 1;
}
#sms-calc-app .sms-calc__char-tile {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 34px; padding: 0 5px; border-radius: 5px;
  font-size: 15px; font-weight: 700; cursor: default; border: none;
  font-family: inherit;
}
#sms-calc-app .sms-calc__char-tile:hover { transform: translateY(-1px); }
#sms-calc-app .sms-calc__char-tile--gsm     { background: #dcfce7; color: #14532d; }
#sms-calc-app .sms-calc__char-tile--ext     { background: #fef9c3; color: #713f12; }
#sms-calc-app .sms-calc__char-tile--unicode { background: #fee2e2; color: #7f1d1d; }
#sms-calc-app .sms-calc__char-tile--space   { background: var(--surface-2); color: var(--text-3); font-size: 11px; }

/* Clickable unicode tiles */
#sms-calc-app .sms-calc__char-tile--clickable {
  cursor: pointer;
  position: relative;
  transition: transform .1s, background .12s, box-shadow .12s;
}
#sms-calc-app .sms-calc__char-tile--clickable:hover {
  background: #fecaca;
  box-shadow: 0 2px 6px rgba(185,28,28,.25);
  transform: translateY(-2px);
}
#sms-calc-app .sms-calc__char-tile--clickable::after {
  content: '↺';
  position: absolute;
  top: -3px; right: -3px;
  font-size: 9px;
  font-weight: 700;
  background: var(--red);
  color: #fff;
  width: 13px; height: 13px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
#sms-calc-app .sms-calc__char-tile--clickable:hover::after { opacity: 1; }
#sms-calc-app .sms-calc__char-tile--clickable:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* Token tile */
#sms-calc-app .sms-calc__token-tile {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  height: 34px; padding: 2px 10px; border-radius: 20px;
  background: var(--teal-light); color: var(--teal);
  font-weight: 700; line-height: 1.1; font-family: inherit; gap: 1px; border: none;
}
#sms-calc-app .sms-calc__token-name { font-size: 11.5px; }
#sms-calc-app .sms-calc__token-range { font-size: 8.5px; font-weight: 500; opacity: .7; letter-spacing: .04em; }

#sms-calc-app .sms-calc__part-footer {
  display: flex; align-items: flex-start; gap: 5px;
  margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border-2);
  font-size: 11px; color: var(--text-3); line-height: 1.5;
}
#sms-calc-app .sms-calc__part-footer strong { color: var(--text-2); font-weight: 600; }

/* Notes */
#sms-calc-app .notes-wrap { margin: 0; }
#sms-calc-app .notes-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 8px;
}
#sms-calc-app .sms-calc__note {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 11px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-left-width: 3px; border-radius: var(--rad-sm);
  color: var(--text-2); font-size: 12.5px; line-height: 1.55;
}
#sms-calc-app .sms-calc__note--warn { border-left-color: var(--amber); }
#sms-calc-app .sms-calc__note--info { border-left-color: var(--navy-mid); }
#sms-calc-app .sms-calc__note-icon { font-size: 13px; flex-shrink: 0; color: var(--text-3); }
#sms-calc-app .sms-calc__note--warn .sms-calc__note-icon { color: var(--amber); }
#sms-calc-app .sms-calc__note strong { color: var(--navy); font-weight: 600; }

#sms-calc-app .sms-calc__char-table {
  margin-top: 6px; border-collapse: collapse; font-size: 12px; width: 100%; max-width: 420px;
}
#sms-calc-app .sms-calc__char-table tbody tr { border-top: 1px solid rgba(0,0,0,.06); }
#sms-calc-app .sms-calc__char-table td { padding: 4px 5px 4px 0; vertical-align: middle; line-height: 1.4; }
#sms-calc-app .sms-calc__char-table-tile { width: 44px; }
#sms-calc-app .sms-calc__char-table-tile .sms-calc__char-tile { min-width: 28px; height: 28px; font-size: 13px; }
#sms-calc-app .sms-calc__char-table-cp { font-family: 'SFMono-Regular','Consolas',monospace; color: var(--text-3); width: 70px; font-size: 11px; }
#sms-calc-app .sms-calc__char-table-count { font-variant-numeric: tabular-nums; color: var(--text-3); width: 30px; text-align: right; padding-right: 8px !important; }
#sms-calc-app .sms-calc__char-table-hint { color: var(--text-3); font-style: italic; font-size: 11px; }

/* ════════════════════════════════════════════
   DIALOGS (share + replace)
   ════════════════════════════════════════════ */
#sms-calc-app .dialog-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(13,27,62,.65);
}
#sms-calc-app .dialog {
  position: relative; background: #fff; border-radius: var(--rad-lg);
  max-width: 580px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(15,31,61,.3);
}
#sms-calc-app .dialog--narrow { max-width: 460px; }
#sms-calc-app .dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-2);
}
#sms-calc-app .dialog-title { font-size: 15px; font-weight: 700; margin: 0; color: var(--navy); }
#sms-calc-app .dialog-close {
  background: none; border: none; font-size: 20px; line-height: 1;
  color: var(--text-3); cursor: pointer; padding: 4px 8px;
  border-radius: 4px; font-family: inherit;
}
#sms-calc-app .dialog-close:hover { background: var(--surface-2); color: var(--navy); }
#sms-calc-app .dialog-body { padding: 0; }
#sms-calc-app .dialog-section {
  padding: 14px 18px; border-bottom: 1px solid var(--border-2);
}
#sms-calc-app .dialog-section:last-child { border-bottom: none; }
#sms-calc-app .dialog-section-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 5px;
}
#sms-calc-app .dialog-section-hint {
  font-size: 12px; color: var(--text-2); line-height: 1.5; margin: 0 0 9px;
}
#sms-calc-app .dialog-textarea-wrap { display: flex; gap: 7px; align-items: stretch; }
#sms-calc-app .dialog-textarea {
  flex: 1; font-family: 'SFMono-Regular','Consolas',monospace; font-size: 11.5px;
  padding: 7px 9px; line-height: 1.5; color: var(--navy);
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--rad-sm); outline: none; resize: vertical; min-height: 60px;
  word-break: break-all;
}
#sms-calc-app .dialog-textarea:focus { border-color: var(--navy-mid); background: var(--surface); }
#sms-calc-app .dialog-copy-btn {
  align-self: flex-start; background: #fff; border: 1px solid var(--border);
  border-radius: var(--rad-sm); padding: 6px 12px; font-size: 12px; font-weight: 700;
  color: var(--navy); cursor: pointer; white-space: nowrap; font-family: inherit;
}
#sms-calc-app .dialog-copy-btn:hover { background: var(--surface-2); }
#sms-calc-app .dialog-copy-btn--primary { background: var(--navy); border-color: var(--navy); color: #fff; }
#sms-calc-app .dialog-copy-btn--primary:hover { background: var(--navy-mid); border-color: var(--navy-mid); }
#sms-calc-app .dialog-import-status { font-size: 11.5px; margin: 8px 0 0; min-height: 1em; color: var(--text-3); }
#sms-calc-app .dialog-import-status.is-success { color: var(--green); font-weight: 600; }
#sms-calc-app .dialog-import-status.is-error { color: var(--red); }

/* ── Share-modal visual hierarchy ── */
#sms-calc-app .dialog-section--primary {
  background: linear-gradient(180deg, #f0f4fb 0%, #f7f9fc 100%);
  border-left: 3px solid var(--navy-mid);
}
#sms-calc-app .dialog-section--foot { background: var(--surface-2); padding-top: 12px; padding-bottom: 12px; }
#sms-calc-app .dialog-section-title {
  display: flex; align-items: center; gap: 7px;
}
#sms-calc-app .dialog-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
#sms-calc-app .dialog-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 3px; padding: 1px 6px;
  letter-spacing: .04em;
}
#sms-calc-app .dialog-badge--rec {
  color: #065f46; background: #d1fae5; border-color: #a7f3d0;
}
#sms-calc-app .dialog-section-subhint {
  font-size: 11px; color: var(--text-3); line-height: 1.5; margin: 8px 0 0;
}
#sms-calc-app .dialog-callout {
  font-size: 11.5px; line-height: 1.5; margin: 9px 0 0;
  padding: 7px 10px; border-radius: var(--rad-sm);
  background: var(--surface-2); color: var(--text-2);
  border-left: 3px solid var(--border);
}
#sms-calc-app .dialog-callout.is-soft {
  background: #fef9c3; color: #78350f; border-left-color: var(--amber);
}
#sms-calc-app .dialog-callout.is-error {
  background: #fee2e2; color: #7f1d1d; border-left-color: var(--red);
}
#sms-calc-app .dialog-btn-stack {
  display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}
#sms-calc-app .dialog-btn-stack .dialog-copy-btn { align-self: stretch; }

/* Collapsible config-string section */
#sms-calc-app .dialog-section--collapsible { padding: 0; }
#sms-calc-app .dialog-collapse-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 14px 18px;
}
#sms-calc-app .dialog-collapse-summary::-webkit-details-marker { display: none; }
#sms-calc-app .dialog-collapse-summary::marker { content: ''; }
#sms-calc-app .dialog-collapse-summary:hover { background: var(--surface-2); }
#sms-calc-app .dialog-section--collapsible[open] .dialog-collapse-summary {
  border-bottom: 1px solid var(--border-2);
}
#sms-calc-app .dialog-collapse-summary .dialog-section-title { margin: 0; }
#sms-calc-app .dialog-collapse-caret {
  font-size: 10px; color: var(--text-3); transition: transform .2s; flex-shrink: 0;
}
#sms-calc-app .dialog-section--collapsible[open] .dialog-collapse-caret { transform: rotate(90deg); }
#sms-calc-app .dialog-collapse-body { padding: 14px 18px; }

/* Option checkbox rows in dialogs */
#sms-calc-app .dialog-opt {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--text-2); line-height: 1.45;
  cursor: pointer; margin-top: 4px;
}
#sms-calc-app .dialog-opt input[type="checkbox"] {
  margin: 1px 0 0; accent-color: var(--navy-mid); cursor: pointer; flex-shrink: 0;
}
#sms-calc-app .dialog-opt--sub {
  margin-top: 8px; padding-left: 10px;
  border-left: 2px solid var(--border-2);
}

/* Replace dialog specifics */
#sms-calc-app .replace-preview {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); padding: 12px 14px;
  border-radius: var(--rad-md); margin-bottom: 12px;
  border: 1px solid var(--border-2);
}
#sms-calc-app .replace-preview-tile {
  background: #fee2e2; color: #7f1d1d;
  font-size: 24px; font-weight: 700;
  min-width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; flex-shrink: 0;
}
#sms-calc-app .replace-preview-info { flex: 1; min-width: 0; }
#sms-calc-app .replace-preview-info p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
#sms-calc-app .replace-preview-info code {
  font-family: 'SFMono-Regular','Consolas',monospace;
  font-size: 11.5px; color: var(--text-3); background: #fff;
  padding: 1px 5px; border-radius: 3px; border: 1px solid var(--border-2);
}
#sms-calc-app .replace-count {
  font-size: 11.5px; color: var(--text-3); margin-top: 2px;
}
#sms-calc-app .replace-input {
  width: 100%; height: 40px; padding: 0 12px;
  font-family: 'SFMono-Regular','Consolas',monospace;
  font-size: 18px; color: var(--navy);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--rad-sm); outline: none;
  transition: border-color .15s;
}
#sms-calc-app .replace-input:focus { border-color: var(--navy-mid); }
#sms-calc-app .replace-hint {
  font-size: 11.5px; color: var(--text-3); margin-top: 6px; font-style: italic;
}
#sms-calc-app .replace-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap;
}
#sms-calc-app .replace-btn {
  padding: 8px 14px; font-size: 12.5px; font-weight: 700; font-family: inherit;
  border-radius: var(--rad-sm); cursor: pointer; white-space: nowrap;
}
#sms-calc-app .replace-btn--primary { background: var(--navy); color: #fff; border: 1px solid var(--navy); }
#sms-calc-app .replace-btn--primary:hover { background: var(--navy-mid); }
#sms-calc-app .replace-btn--secondary { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
#sms-calc-app .replace-btn--secondary:hover { background: var(--surface-2); }

/* Recommended-replacement row at the top of the dialog */
#sms-calc-app .replace-rec-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-2);
}
#sms-calc-app .replace-btn--rec { display: inline-flex; align-items: baseline; gap: 5px; }
#sms-calc-app .replace-btn--rec strong {
  font-family: 'SFMono-Regular','Consolas',monospace;
  background: rgba(255,255,255,.18); padding: 1px 6px; border-radius: 3px;
}
#sms-calc-app .replace-or { font-size: 11.5px; color: var(--text-3); }
#sms-calc-app .replace-actions-spacer { flex: 1; }

/* Per-character action buttons in the encoding-notes table */
#sms-calc-app .sms-calc__char-table-action {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-left: 4px;
}
#sms-calc-app .char-row-label {
  font-size: 11px; color: var(--text-3); font-style: italic;
}
#sms-calc-app .char-row-btn {
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: var(--rad-sm); cursor: pointer;
  white-space: nowrap; line-height: 1.3; transition: background .12s, border-color .12s;
}
#sms-calc-app .char-row-btn--rec {
  background: #dcfce7; color: #166534; border: 1px solid #86efac;
  font-family: 'SFMono-Regular','Consolas',monospace;
}
#sms-calc-app .char-row-btn--rec:hover { background: #bbf7d0; border-color: #4ade80; }
#sms-calc-app .char-row-btn--custom {
  background: #fff; color: var(--text-2); border: 1px solid var(--border);
}
#sms-calc-app .char-row-btn--custom:hover { background: var(--surface-2); color: var(--navy); }

/* ── Responsive ── */
@media (max-width: 880px) {
  #sms-calc-app { padding: 8px; }
  #sms-calc-app .layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }
  #sms-calc-app .left-col {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }
  #sms-calc-app .right-col {
    overflow-y: visible;
  }
  #sms-calc-app .stats { grid-template-columns: repeat(2, 1fr); }
  #sms-calc-app .top-input { width: 100%; }
  #sms-calc-app .top { position: static; }
}
