.panel-scroll {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

  .section-label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text3);
    margin-bottom: 10px;
  }

  .section-label-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .hint-text {
    font-size: 12px;
    color: var(--text3);
    margin-top: 10px;
    line-height: 1.65;
  }

  .pattern-input {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    outline: none;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    color: var(--text);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  }

  .pattern-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }

  .flag-row {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .mode-row {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .mode-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    font-family: var(--sans);
    font-size: 12px;
    color: var(--text2);
    user-select: none;
    cursor: pointer;
  }

  .mode-item input {
    margin: 0;
  }

  .flag-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text2);
    user-select: none;
    cursor: pointer;
  }

  .flag-item input {
    margin: 0;
  }

  .err-box {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: var(--radius);
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    font-size: 12px;
    line-height: 1.55;
    word-break: break-word;
  }

  .warn-box {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: var(--radius);
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
    font-size: 12px;
    line-height: 1.55;
    word-break: break-word;
  }

  .flag-help {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    padding: 10px 12px;
  }

  .flag-help summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text2);
    user-select: none;
  }

  .flag-help-body {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text3);
  }

  .flag-help-body b {
    font-family: var(--mono);
    color: var(--text2);
  }

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

  .preset-item {
    text-align: left;
    padding: 12px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    cursor: pointer;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  }

  .preset-item:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
  }

  .preset-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
  }

  .preset-desc {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text3);
    line-height: 1.55;
  }

  .preset-pattern {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text2);
    word-break: break-word;
  }

  .btn-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .auto-run {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    font-size: 12px;
    color: var(--text2);
    cursor: pointer;
    user-select: none;
  }

  .auto-run input {
    margin: 0;
  }

  .btn-primary {
    width: 100%;
    padding: 12px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
    box-shadow: 0 2px 8px var(--accent-glow);
  }

  .btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px var(--accent-glow);
  }

  .btn-primary:active {
    transform: translateY(1px);
  }

  .btn-secondary {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-muted);
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
  }

  .btn-secondary:hover {
    border-color: var(--border-strong);
    color: var(--text);
  }

  .btn-inline {
    width: auto;
  }

.canvas-wrap {
  min-height: 0;
  display: grid;
  grid-template-rows: 260px minmax(0, 1fr);
  gap: 14px;
}

.regex-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

  .editor-title {
    font-size: 12px;
    color: var(--text3);
    letter-spacing: 0.03em;
    margin-bottom: 8px;
  }

  .editor-shell {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  }

  .editor-shell:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }

  .editor-input {
    width: 100%;
    height: 100%;
    min-height: 140px;
    resize: vertical;
    overflow: auto;
    padding: 12px 12px;
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    color: var(--text);
  }

.regex-preview {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .preview-title {
    font-size: 12px;
    color: var(--text3);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .summary {
    font-weight: 500;
    color: var(--text3);
  }

  .summary.is-success {
    color: #0f766e;
  }

  .summary.is-danger {
    color: #dc2626;
  }

  .preview-box {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: auto;
  }

  .highlight-pre {
    margin: 0;
    padding: 12px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
  }

  .hl {
    background: rgba(79, 70, 229, 0.18);
    border: 1px solid rgba(79, 70, 229, 0.22);
    border-radius: 6px;
    padding: 0 2px;
  }

  .matches-box {
    flex: 1;
    min-height: 160px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: auto;
  }

  .empty-output {
    padding: 14px 12px;
    font-size: 12px;
    color: var(--text3);
  }

  .match-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

  .match-item:last-child {
    border-bottom: none;
  }

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

  .match-title {
    font: 600 12px var(--mono);
    color: var(--text2);
  }

  .match-pos {
    font: 500 12px var(--mono);
    color: var(--text3);
  }

  .match-body {
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
  }

  .group-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .group-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-family: var(--mono);
    font-size: 12px;
  }

  .group-row span {
    color: var(--text3);
    min-width: 46px;
  }

  .group-row code {
    font-family: var(--mono);
    color: var(--text);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px 6px;
    word-break: break-word;
  }

  .lang-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .tab {
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text2);
    font: 600 12px var(--mono);
    cursor: pointer;
    transition: all 0.2s var(--ease);
  }

  .tab:hover {
    border-color: var(--border-strong);
    color: var(--text);
  }

  .tab.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
  }

  .code-box {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 240px;
  }

  .code-actions {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    background: var(--surface-muted);
  }

  .code-pre {
    margin: 0;
    padding: 12px;
    flex: 1;
    overflow: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre;
  }

  @media (max-width: 1100px) {
    .btn-row {
      flex-direction: row;
    }

    .btn-row > * {
      flex: 1;
    }
  }

  @media (max-width: 860px) {
    .btn-row {
      flex-direction: column;
    }
  }
