.icon-text-tools { background: #e8f7fa; color: #0d8c9a; }
.platform-tab.text-tools-nav-tab.is-tool-open {
  background: linear-gradient(135deg, #2d74ea, #11a6a0);
  color: #fff;
  box-shadow: 0 5px 13px rgba(30, 132, 177, 0.25);
}
.platform-tab.text-tools-nav-tab.is-tool-open:hover:not(:disabled) {
  background: linear-gradient(135deg, #2d74ea, #11a6a0);
  color: #fff;
}
.platform-tab.text-tools-nav-tab.is-tool-open .platform-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }

.text-tools {
  margin: -8px 0 24px;
  overflow: hidden;
  border: 1px solid #cdd9eb;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(43, 65, 100, 0.07);
}

.text-tools-body {
  padding: 22px;
  background: linear-gradient(180deg, #f8fbff 0, #fff 96px);
}

.text-tools-intro,
.text-tool-panel-heading,
.text-tool-label-row,
.text-split-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.text-tools-kicker {
  margin: 0 0 4px;
  color: #2473df;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-tools-intro h2 { margin: 0; font-size: 19px; }
.text-tools-privacy {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #bce8dc;
  border-radius: 10px;
  background: #edfbf7;
  color: #16735f;
  font-size: 13px;
  font-weight: 700;
}
.text-tools-privacy span:first-child { color: #18a985; }

.text-tool-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 18px 0 14px;
}

.text-tool-tab {
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 11px 14px;
  border: 1px solid #d5dfec;
  border-radius: 11px;
  background: #fff;
  color: #2d405d;
  cursor: pointer;
  text-align: left;
}
.text-tool-tab strong { font-size: 14px; }
.text-tool-tab small { color: #718096; font-size: 12px; }
.text-tool-tab:hover { border-color: #8badde; background: #f7faff; }
.text-tool-tab:focus-visible { outline: 3px solid rgba(51, 121, 246, 0.18); outline-offset: 1px; }
.text-tool-tab.is-active {
  border-color: #3a79e4;
  background: #edf4ff;
  color: #1557ba;
  box-shadow: inset 0 0 0 1px rgba(58, 121, 228, 0.16);
}
.text-tool-tab.is-active small { color: #4973ad; }

.text-tool-panel {
  padding: 20px;
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  background: #fff;
}

.text-tool-panel-heading { align-items: flex-start; margin-bottom: 15px; }
.text-tool-panel-heading h3 { margin: 0; font-size: 18px; }
.text-tool-panel-heading p { margin: 5px 0 0; color: #66768d; font-size: 13px; line-height: 1.55; }
.text-tool-format {
  flex: 0 0 auto;
  max-width: 52%;
  padding: 6px 9px;
  border-radius: 8px;
  background: #f1f5fa;
  color: #566a84;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
}

.text-tool-editor-grid,
.text-compare-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.text-tool-output-wide { grid-column: 1 / -1; }
.text-tool-editor { min-width: 0; }
.text-tool-editor > label,
.text-tool-label-row label,
.text-order-fields label > span,
.text-simple-fields label > span,
.text-split-input-wrap > span,
.text-split-controls label > span {
  display: block;
  margin-bottom: 7px;
  color: #2f425e;
  font-size: 14px;
  font-weight: 800;
}
.text-tool-editor textarea,
.text-split-input-wrap textarea {
  min-height: 190px;
  padding: 12px 13px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}
.text-tool-editor textarea[readonly] { background: #f8fafc; }
.text-tool-label-row { gap: 8px; }
.text-tool-count {
  min-width: 26px;
  margin-bottom: 7px;
  padding: 2px 8px;
  border-radius: 99px;
  background: #eaf1fb;
  color: #3366a5;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.text-tool-help { margin: 7px 0 0; color: #738197; font-size: 12px; line-height: 1.55; }
.text-tool-caution { margin: 7px 0 0; color: #9a6811; font-size: 12px; line-height: 1.55; }
.text-tool-status { min-height: 20px; margin: 7px 0 0; color: #526983; font-size: 12px; line-height: 1.55; }
.text-tool-status.is-error { color: #bd2430; }
.text-tool-status.is-success { color: #087b52; }

.text-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}
.text-tool-actions .button { min-height: 38px; }
.button-quiet { border-color: transparent; color: #64748b; }
.button-quiet:hover:not(:disabled) { background: #f1f5f9; }
.button-compact {
  min-height: 32px;
  padding: 5px 10px;
  border-color: #cbd7e6;
  color: #4d617b;
  font-size: 12px;
}

.text-smart-settings {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #dce6f2;
  border-radius: 12px;
  background: #f8fbff;
}
.text-smart-separator-fields {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  margin-bottom: 10px;
}
.text-smart-manual-separator {
  align-self: stretch;
  padding: 10px 12px;
  border: 1px dashed #bfcee2;
  border-radius: 10px;
  background: #f8fbff;
}
.text-smart-manual-separator summary { color: #315f9d; cursor: pointer; font-size: 13px; font-weight: 800; }
.text-smart-manual-separator[open] summary { margin-bottom: 10px; }
.text-smart-manual-separator label { gap: 6px; }
.text-smart-manual-separator p { margin: 7px 0 0; color: #6b7d94; font-size: 12px; line-height: 1.5; }
.text-smart-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 9px;
}
.text-smart-action-row .button { min-height: 38px; }
.text-smart-mode.is-active {
  border-color: #3379f6;
  background: #3379f6;
  color: #fff;
  box-shadow: 0 5px 12px rgba(51, 121, 246, 0.2);
}
.text-smart-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
  padding: 9px 11px;
  border: 1px solid #d7e3f1;
  border-radius: 9px;
  background: #fff;
}
.text-smart-submit-row p { margin: 0; color: #5f7087; font-size: 13px; line-height: 1.5; }
.text-smart-submit-row .button { flex: 0 0 auto; min-height: 38px; }
.text-smart-field-settings {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.text-smart-field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: #334861;
  font-size: 13px;
}
.text-smart-field-heading > div { min-width: 0; }
.text-smart-segment-summary { margin: 4px 0 0; color: #718096; font-size: 12px; font-weight: 500; }
.text-smart-segment-summary.is-error { color: #bd2430; }
.text-smart-field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.text-smart-field-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #d7e2ef;
  border-radius: 8px;
  background: #fff;
  color: #40536d;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.text-smart-field-grid label:hover { border-color: #8cadd8; }
.text-smart-field-grid input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #3379f6;
}
.text-smart-field-grid label > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.text-smart-field-grid strong { color: #30435e; font-size: 14px; }
.text-smart-field-grid small {
  overflow: hidden;
  color: #738197;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-common-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.text-common-action {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #d4deeb;
  border-radius: 9px;
  background: #fff;
  color: #40536d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}
.text-common-action:hover { border-color: #8badde; background: #f7faff; }
.text-common-action:focus-visible { outline: 3px solid rgba(51, 121, 246, 0.18); outline-offset: 1px; }
.text-common-action.is-active {
  border-color: #3a79e4;
  background: #edf4ff;
  color: #1557ba;
}
.text-common-pane {
  padding: 16px;
  border: 1px solid #e0e7f0;
  border-radius: 11px;
  background: #fbfdff;
}
.text-common-pane .text-tool-panel-heading { margin-bottom: 13px; }

.text-order-fields {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(190px, 0.7fr) minmax(260px, 1.6fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.text-order-fields .text-tool-help { align-self: center; margin: 21px 0 0; }
.text-order-fields input,
.text-simple-fields input,
.text-simple-fields select,
.text-split-controls input,
.text-split-cell-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #d2ddea;
  border-radius: 8px;
  background: #fff;
  color: #1f334f;
  font: inherit;
  outline: none;
}
.text-order-fields input:focus,
.text-simple-fields input:focus,
.text-simple-fields select:focus,
.text-split-controls input:focus,
.text-split-cell-input:focus {
  border-color: #5d8ee5;
  box-shadow: 0 0 0 3px rgba(65, 124, 226, 0.13);
}

.text-simple-fields {
  display: grid;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.text-simple-fields label { min-width: 0; }
.text-affix-fields { grid-template-columns: minmax(170px, 0.7fr) repeat(2, minmax(210px, 1fr)); }
.text-replace-fields { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.text-break-fields { grid-template-columns: minmax(180px, 360px); }
.text-compare-result-controls {
  grid-template-columns: minmax(190px, 0.45fr) minmax(260px, 1fr);
  margin-bottom: 0;
}
.text-compare-output-label { align-self: end; }
.text-tool-output-wide textarea { min-height: 145px; }

.text-split-input-wrap { display: block; }
.text-split-input-wrap textarea { min-height: 125px; }
.text-split-controls {
  display: grid;
  grid-template-columns: minmax(130px, 0.55fr) minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}
.text-split-search-label { min-width: 0; }
.text-split-controls .button { min-height: 40px; }

.text-split-selection-bar {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #dce5ef;
  border-radius: 10px;
  background: #f7f9fc;
}
.text-split-selection-bar > div:first-child { display: grid; gap: 3px; }
.text-split-selection-bar strong { color: #30435e; font-size: 13px; }
.text-split-selection-bar span { color: #718096; font-size: 12px; }
.text-split-selection-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.text-split-table-wrap {
  max-height: 390px;
  margin-top: 10px;
  overflow: auto;
  border: 1px solid #d8e1ec;
  border-radius: 10px;
  background: #fff;
}
.text-split-table { width: 100%; min-width: 560px; border-collapse: collapse; table-layout: auto; }
.text-split-table th,
.text-split-table td { min-width: 150px; padding: 8px; border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; text-align: left; }
.text-split-table th:last-child,
.text-split-table td:last-child { border-right: 0; }
.text-split-table tr:last-child td { border-bottom: 0; }
.text-split-table th { position: sticky; z-index: 2; top: 0; background: #edf3fb; color: #344a68; font-size: 12px; }
.text-split-header { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.text-split-header input { width: 20px; height: 20px; margin: 0; accent-color: #3379f6; }
.text-split-header strong { margin-right: auto; }
.text-split-column-action {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #c6d3e3;
  border-radius: 6px;
  background: #fff;
  color: #526983;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.text-split-column-action:hover:not(:disabled) { border-color: #7399cd; background: #f3f7fc; }
.text-split-column-action:disabled { cursor: not-allowed; opacity: 0.35; }
.text-split-column-delete { color: #b52b37; }
.text-split-cell-input { min-width: 150px; min-height: 34px; padding: 6px 8px; border-color: transparent; border-radius: 6px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.text-split-cell-input:hover { border-color: #d6e0ec; }
.text-split-row-hidden { display: none; }
.text-split-empty { height: 100px; color: #79879a; font-size: 13px; text-align: center !important; }

@media (max-width: 900px) {
  .text-tool-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .text-smart-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .text-common-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .text-tool-editor-grid,
  .text-compare-editor-grid { grid-template-columns: 1fr; }
  .text-tool-output-wide { grid-column: auto; }
  .text-order-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .text-order-fields .text-tool-help { grid-column: 1 / -1; margin-top: 0; }
  .text-affix-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .text-affix-fields label:first-child { grid-column: 1 / -1; }
  .text-split-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .text-tools { margin: -4px 0 14px; border-radius: 12px; }
  .text-tools-body { padding: 13px; }
  .text-tools-intro { align-items: flex-start; flex-direction: column; gap: 9px; }
  .text-tools-privacy { width: 100%; }
  .text-tool-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 13px; }
  .text-tool-tab { min-height: 52px; }
  .text-tool-panel { padding: 13px; }
  .text-tool-panel-heading { display: block; }
  .text-tool-format { display: block; max-width: none; margin-top: 9px; text-align: left; }
  .text-tool-editor textarea { min-height: 150px; }
  .text-order-fields,
  .text-simple-fields,
  .text-split-controls { grid-template-columns: 1fr; }
  .text-smart-action-row .button { flex: 1 1 calc(50% - 9px); }
  .text-smart-submit-row { align-items: stretch; flex-direction: column; }
  .text-smart-submit-row .button { width: 100%; }
  .text-common-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .text-affix-fields label:first-child { grid-column: auto; }
  .text-tool-actions .button { flex: 1 1 calc(50% - 9px); }
  .text-split-selection-bar { align-items: stretch; flex-direction: column; }
  .text-split-selection-actions { justify-content: flex-start; }
  .text-split-selection-actions .button { flex: 1 1 calc(50% - 6px); }
}

@media (max-width: 430px) {
  .text-tool-tabs { grid-template-columns: 1fr; }
  .text-smart-field-grid,
  .text-common-actions { grid-template-columns: 1fr; }
  .text-smart-field-heading { align-items: flex-start; flex-direction: column; }
  .text-smart-action-row .button { flex-basis: 100%; }
}
