.pen-pressure-embed {
  margin: 1rem;
  padding: 0;
  background: #f8fafc;
  border: 1px solid #94a3b8;
  border-radius: 14px;
}

.pen-pressure-embed > summary {
  padding: 1rem 1.1rem;
  color: #0f172a;
  font-weight: 800;
  cursor: pointer;
}

.pen-pressure-embed[open] > summary {
  border-bottom: 1px solid #cbd5e1;
}

.pen-pressure-embed-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.pen-pressure-embed-intro p {
  margin: 0;
  color: #475569;
  line-height: 1.55;
}

.pen-pressure-embed-intro a {
  flex: 0 0 auto;
  padding: 0.65rem 0.9rem;
  color: #fff;
  background: #0f766e;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.pen-pressure-embed .pen-pressure-tester {
  margin: 0 1rem 1rem;
  width: calc(100% - 2rem);
}

html.dark-theme .pen-pressure-embed,
[data-theme="dark"] .pen-pressure-embed {
  background: #111827;
  border-color: #475569;
}

html.dark-theme .pen-pressure-embed > summary,
[data-theme="dark"] .pen-pressure-embed > summary {
  color: #f8fafc;
}

html.dark-theme .pen-pressure-embed-intro p,
[data-theme="dark"] .pen-pressure-embed-intro p {
  color: #cbd5e1;
}

.pen-pressure-tester {
  --pen-accent: #0f766e;
  --pen-accent-strong: #115e59;
  --pen-accent-soft: #ccfbf1;
  --pen-blue: #2563eb;
  --pen-surface: #ffffff;
  --pen-surface-soft: #f8fafc;
  --pen-border: #cbd5e1;
  --pen-text: #0f172a;
  --pen-muted: #475569;
  width: 100%;
  color: var(--pen-text);
  background: var(--pen-surface);
  border: 1px solid var(--pen-border);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
  overflow: hidden;
}

.pen-pressure-tester *,
.pen-pressure-tester *::before,
.pen-pressure-tester *::after {
  box-sizing: border-box;
}

.pen-pressure-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, #ecfeff, #f0fdf4);
  border-bottom: 1px solid var(--pen-border);
}

.pen-pressure-status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  color: var(--pen-text);
  font-weight: 700;
}

.pen-pressure-status-dot {
  flex: 0 0 auto;
  width: 0.72rem;
  height: 0.72rem;
  background: #64748b;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.13);
}

.pen-pressure-status[data-state="pen"] .pen-pressure-status-dot {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
}

.pen-pressure-status[data-state="limited"] .pen-pressure-status-dot {
  background: #d97706;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.14);
}

.pen-pressure-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.pen-pressure-actions button {
  min-height: 40px;
  padding: 0.58rem 0.9rem;
  color: #fff;
  background: var(--pen-accent);
  border: 1px solid var(--pen-accent);
  border-radius: 9px;
  font: inherit;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
}

.pen-pressure-actions button:first-child {
  color: var(--pen-accent-strong);
  background: #fff;
}

.pen-pressure-actions button:hover,
.pen-pressure-actions button:focus-visible {
  background: var(--pen-accent-strong);
  color: #fff;
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.pen-pressure-instructions,
.pen-pressure-hold-hint {
  margin: 0;
  color: var(--pen-muted);
  line-height: 1.6;
}

.pen-pressure-instructions {
  padding: 1rem 1.2rem 0;
}

.pen-pressure-guided {
  padding: 1rem 1.2rem 0;
}

.pen-pressure-guided h3 {
  margin: 0 0 0.65rem;
  color: var(--pen-text);
  font-size: 1rem;
}

.pen-pressure-guided ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pen-pressure-guided li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.55rem;
  align-items: center;
  min-width: 0;
  padding: 0.65rem;
  background: var(--pen-surface-soft);
  border: 1px solid var(--pen-border);
  border-radius: 10px;
}

.pen-pressure-guided li > span {
  grid-row: 1 / span 2;
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  color: #fff;
  background: #64748b;
  border-radius: 999px;
  font-weight: 800;
}

.pen-pressure-guided li strong {
  color: var(--pen-text);
  font-size: 0.82rem;
  line-height: 1.25;
}

.pen-pressure-guided li em {
  color: var(--pen-muted);
  font-size: 0.74rem;
  font-style: normal;
}

.pen-pressure-guided li.is-complete {
  background: rgba(220, 252, 231, 0.72);
  border-color: #86efac;
}

.pen-pressure-guided li.is-complete > span {
  background: #15803d;
}

.pen-pressure-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(270px, 0.8fr);
  gap: 1rem;
  padding: 1rem 1.2rem 1.2rem;
}

.pen-pressure-draw-panel,
.pen-pressure-side,
.pen-pressure-chart-card,
.pen-pressure-wobble-card,
.pen-pressure-history {
  min-width: 0;
  background: var(--pen-surface-soft);
  border: 1px solid var(--pen-border);
  border-radius: 14px;
}

.pen-pressure-canvas-shell {
  position: relative;
  width: 100%;
  height: min(58vh, 590px);
  min-height: 390px;
  overflow: hidden;
  background:
    linear-gradient(rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    #fff;
  background-size: 32px 32px;
  border-radius: 13px 13px 0 0;
}

.pen-pressure-canvas-shell::after {
  content: "";
  position: absolute;
  inset: 11% 12%;
  border-top: 2px dashed rgba(37, 99, 235, 0.3);
  transform: rotate(28deg);
  transform-origin: center;
  pointer-events: none;
}

.pen-pressure-canvas-shell canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.pen-pressure-canvas-shell canvas:focus-visible {
  outline: 4px solid rgba(37, 99, 235, 0.35);
  outline-offset: -4px;
}

.pen-pressure-canvas-hint {
  position: absolute;
  z-index: 2;
  inset-inline: 1rem;
  inset-block-start: 1rem;
  max-width: 36rem;
  padding: 0.75rem 0.9rem;
  color: #334155;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 10px;
  line-height: 1.45;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.pen-pressure-tester[data-has-input="true"] .pen-pressure-canvas-hint {
  opacity: 0;
}

.pen-pressure-hold-hint {
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
}

.pen-pressure-side {
  padding: 1rem;
}

.pen-pressure-side h3,
.pen-pressure-analysis h3,
.pen-pressure-history h3,
.pen-pressure-chart-card h4,
.pen-pressure-wobble-card h4 {
  margin: 0;
  color: var(--pen-text);
  font-weight: 800;
  line-height: 1.25;
}

.pen-pressure-side > h3 + * {
  margin-top: 0.8rem;
}

.pen-pressure-side > h3:not(:first-child) {
  margin-top: 1.2rem;
}

.pen-pressure-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.pen-pressure-stat-grid > div {
  min-width: 0;
  padding: 0.65rem;
  background: #fff;
  border: 1px solid #dbe3ed;
  border-radius: 10px;
}

.pen-pressure-stat-grid strong,
.pen-pressure-stat-grid span {
  display: block;
}

.pen-pressure-stat-grid strong {
  overflow: hidden;
  color: var(--pen-accent-strong);
  font-size: 1rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pen-pressure-stat-grid span {
  margin-top: 0.25rem;
  color: var(--pen-muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.pen-pressure-capabilities,
.pen-pressure-wobble-card dl {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.pen-pressure-capabilities > div,
.pen-pressure-wobble-card dl > div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.42rem;
  border-bottom: 1px solid #e2e8f0;
}

.pen-pressure-capabilities dt,
.pen-pressure-wobble-card dt {
  color: var(--pen-muted);
}

.pen-pressure-capabilities dd,
.pen-pressure-wobble-card dd {
  margin: 0;
  color: var(--pen-text);
  font-weight: 700;
  text-align: end;
}

.pen-pressure-analysis {
  padding: 0 1.2rem 1.2rem;
}

.pen-pressure-analysis > h3 {
  margin-bottom: 0.8rem;
}

.pen-pressure-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(270px, 0.75fr);
  gap: 1rem;
}

.pen-pressure-chart-card,
.pen-pressure-wobble-card {
  padding: 1rem;
}

.pen-pressure-chart-card canvas {
  display: block;
  width: 100%;
  height: 180px;
  margin-top: 0.75rem;
  background: #fff;
  border: 1px solid #dbe3ed;
  border-radius: 10px;
}

.pen-pressure-distribution {
  margin-top: 0.9rem;
}

.pen-pressure-distribution > strong {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
}

.pen-pressure-distribution > div {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  height: 58px;
}

.pen-pressure-distribution span {
  position: relative;
  display: block;
  height: 100%;
  overflow: hidden;
  background: #dbeafe;
  border-radius: 5px 5px 2px 2px;
}

.pen-pressure-distribution i {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  display: block;
  height: 0%;
  background: linear-gradient(180deg, #22c55e, #0f766e);
  transition: height 0.18s ease;
}

.pen-pressure-reach-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.pen-pressure-reach-grid > div {
  padding: 0.65rem;
  background: #fff;
  border: 1px solid #dbe3ed;
  border-radius: 9px;
}

.pen-pressure-reach-grid span,
.pen-pressure-reach-grid strong {
  display: block;
}

.pen-pressure-reach-grid span {
  color: var(--pen-muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.pen-pressure-reach-grid strong {
  margin-top: 0.35rem;
  color: var(--pen-accent-strong);
}

.pen-pressure-wobble-card dl {
  margin-top: 0.85rem;
}

.pen-pressure-wobble-card p {
  color: var(--pen-muted);
  line-height: 1.55;
}

.pen-pressure-wobble-empty[hidden] {
  display: none;
}

.pen-pressure-history {
  margin: 0 1.2rem 1.2rem;
  padding: 1rem;
}

.pen-pressure-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.pen-pressure-history table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
}

.pen-pressure-history th,
.pen-pressure-history td {
  padding: 0.62rem 0.7rem;
  border-bottom: 1px solid #dbe3ed;
  text-align: start;
  white-space: nowrap;
}

.pen-pressure-history th {
  color: var(--pen-muted);
  background: #f1f5f9;
  font-size: 0.8rem;
}

.pen-pressure-history td {
  color: var(--pen-text);
  font-variant-numeric: tabular-nums;
}

.pen-pressure-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  padding: 0 1.2rem 1.2rem;
}

.pen-pressure-notes p {
  margin: 0;
  padding: 0.8rem;
  color: var(--pen-muted);
  background: #f8fafc;
  border: 1px solid var(--pen-border);
  border-radius: 10px;
  line-height: 1.5;
}

html.dark-theme .pen-pressure-tester,
[data-theme="dark"] .pen-pressure-tester {
  --pen-surface: #111827;
  --pen-surface-soft: #172033;
  --pen-border: #3b475a;
  --pen-text: #f8fafc;
  --pen-muted: #cbd5e1;
  --pen-accent-soft: #134e4a;
  background: var(--pen-surface);
}

html.dark-theme .pen-pressure-toolbar,
[data-theme="dark"] .pen-pressure-toolbar {
  background: linear-gradient(135deg, #0f2f35, #142f29);
}

html.dark-theme .pen-pressure-actions button:first-child,
html.dark-theme .pen-pressure-stat-grid > div,
html.dark-theme .pen-pressure-chart-card canvas,
html.dark-theme .pen-pressure-reach-grid > div,
[data-theme="dark"] .pen-pressure-actions button:first-child,
[data-theme="dark"] .pen-pressure-stat-grid > div,
[data-theme="dark"] .pen-pressure-chart-card canvas,
[data-theme="dark"] .pen-pressure-reach-grid > div {
  color: #d5fff7;
  background: #0f172a;
  border-color: #334155;
}

html.dark-theme .pen-pressure-canvas-shell,
[data-theme="dark"] .pen-pressure-canvas-shell {
  background:
    linear-gradient(rgba(45, 212, 191, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 191, 0.09) 1px, transparent 1px),
    #0b1220;
  background-size: 32px 32px;
}

html.dark-theme .pen-pressure-canvas-hint,
[data-theme="dark"] .pen-pressure-canvas-hint {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.94);
  border-color: #475569;
}

html.dark-theme .pen-pressure-history th,
[data-theme="dark"] .pen-pressure-history th {
  color: #dbeafe;
  background: #0f172a;
}

html.dark-theme .pen-pressure-guided li.is-complete,
[data-theme="dark"] .pen-pressure-guided li.is-complete {
  background: #143c2b;
  border-color: #22c55e;
}

html.dark-theme .pen-pressure-notes p,
[data-theme="dark"] .pen-pressure-notes p {
  background: #0f172a;
  border-color: #334155;
}

.pen-pressure-tester[dir="rtl"] .pen-pressure-history th,
.pen-pressure-tester[dir="rtl"] .pen-pressure-history td {
  text-align: right;
}

@media (max-width: 1000px) {
  .pen-pressure-layout,
  .pen-pressure-analysis-grid {
    grid-template-columns: 1fr;
  }

  .pen-pressure-canvas-shell {
    height: min(56vh, 520px);
  }

  .pen-pressure-guided ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .pen-pressure-embed {
    margin-inline: 0;
    border-inline: 0;
    border-radius: 0;
  }

  .pen-pressure-embed-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .pen-pressure-embed-intro a {
    text-align: center;
  }

  .pen-pressure-embed .pen-pressure-tester {
    margin-inline: 0;
    width: 100%;
  }

  .pen-pressure-tester {
    border-inline: 0;
    border-radius: 0;
  }

  .pen-pressure-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pen-pressure-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pen-pressure-actions button {
    min-width: 0;
    padding-inline: 0.45rem;
    font-size: 0.82rem;
  }

  .pen-pressure-layout,
  .pen-pressure-analysis,
  .pen-pressure-instructions,
  .pen-pressure-guided,
  .pen-pressure-notes {
    padding-inline: 0.75rem;
  }

  .pen-pressure-history {
    margin-inline: 0.75rem;
  }

  .pen-pressure-canvas-shell {
    height: 52vh;
    min-height: 320px;
  }

  .pen-pressure-reach-grid,
  .pen-pressure-notes {
    grid-template-columns: 1fr;
  }

  .pen-pressure-guided ol {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .pen-pressure-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pen-pressure-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pen-pressure-tester *,
  .pen-pressure-tester *::before,
  .pen-pressure-tester *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
