:root {
  --border: #d6d6d6;
  --primary: #1e5f8c;
  --primary-dark: #154866;
  --bg-soft: #f6f7f9;
  --text: #222;
  --error: #b3261e;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  margin: 0;
  background: #fff;
}

.app-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-logo {
  display: block;
  height: 32px;
  width: auto;
  margin: 0 0 0.75rem;
}

.step-indicator {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  color: #888;
  cursor: not-allowed;
}

.step-indicator li.active {
  color: var(--primary);
  font-weight: 600;
}

.step-indicator li.reachable {
  cursor: pointer;
}

.step-indicator li.reachable:hover {
  text-decoration: underline;
}

.header-tabs-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.info-tabs {
  display: flex;
  gap: 1.25rem;
}

.info-tab-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
}

.info-tab-btn:hover {
  color: var(--primary);
}

.info-tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

main#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  padding-bottom: 7rem;
}

.step { display: none; }
.step.active { display: block; }

.info-page { display: none; }
.info-page.active { display: block; }

.info-page h3 {
  margin-top: 1.75rem;
}

.info-page blockquote {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border);
  background: var(--bg-soft);
  color: #444;
  font-size: 0.9rem;
  font-style: italic;
}

.guide-steps {
  padding-left: 1.25rem;
}

.guide-steps li {
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.screenshot-placeholder {
  margin: 0.6rem 0 0;
  padding: 0;
}

.screenshot-placeholder img {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  min-height: 120px;
}

.screenshot-placeholder figcaption {
  font-size: 0.78rem;
  color: #888;
  margin-top: 0.3rem;
}

textarea#claim-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.3rem;
}

.patent-number-input {
  width: 260px;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 960px;
  z-index: 90;
  padding: 0.85rem 1.5rem;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

#analyze-btn { margin-left: auto; }
#continue-to-viz-btn { margin-left: auto; }
#download-png-btn { margin-left: auto; }
#download-docx-btn, #download-docx-element-btn { margin-left: auto; }

button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover { background: var(--bg-soft); }

button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

button.primary:hover { background: var(--primary-dark); }

button.add-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  margin-left: 0.5rem;
}

label.file-btn {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

label.file-btn:hover { background: var(--bg-soft); }

.hint { color: #666; font-size: 0.85rem; }
.loading { color: var(--primary); font-size: 0.85rem; }
.hidden { display: none !important; }

.error-banner {
  background: #fdecea;
  color: var(--error);
  border: 1px solid #f5c2c0;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  max-width: 360px;
}

.toast {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  animation: toast-in 0.15s ease-out;
}

.toast.warning {
  background: #fff3cd;
  color: #6b4400;
  border: 1px solid #f0c36d;
}

.toast.info {
  background: #e7f1f8;
  color: #154866;
  border: 1px solid #b8d4e8;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.modal-box p {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

button.danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

button.danger:hover { background: #8f1f19; }

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.editor-scroll {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 0.4rem;
  scrollbar-gutter: stable;
}

.editor-scroll-half { max-height: 34vh; }
.editor-scroll-full { max-height: 70vh; }

.editor-col h3 {
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
  margin-top: 1.5rem;
}

table.editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table.editor-table td {
  border-bottom: 1px solid #eee;
  padding: 0.3rem 0.3rem;
  vertical-align: top;
}

table.editor-table td.id-cell {
  width: 3.2rem;
  font-weight: 600;
  color: var(--primary);
  padding-top: 0.5rem;
}

table.editor-table input[type="text"] {
  width: 100%;
  border: 1px solid transparent;
  padding: 0.35rem;
  font-size: 0.85rem;
  border-radius: 4px;
  font-family: inherit;
}

table.editor-table input[type="text"]:focus {
  border-color: var(--primary);
  outline: none;
}

table.editor-table button.del-btn {
  border: none;
  background: none;
  color: #999;
  font-size: 0.95rem;
  padding: 0.2rem 0.4rem;
}

table.editor-table button.del-btn:hover { color: var(--error); }

table.editor-table tr.needs-review {
  background: #fff3cd;
}

table.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.5rem 0 1.5rem;
}

table.preview-table th,
table.preview-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

table.preview-table th {
  background: var(--bg-soft);
  font-weight: 600;
}

table.preview-table td.notes-cell {
  width: 35%;
  color: #aaa;
}

.subtab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.subtab-btn {
  border: none;
  background: none;
  padding: 0.5rem 0.2rem;
  margin-right: 1.5rem;
  font-size: 0.9rem;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.subtab-btn:hover {
  color: var(--primary);
}

.subtab-btn.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

#claim-element-table td:first-child {
  width: 55%;
}

.mapping-cell div {
  margin-bottom: 0.2rem;
}

.mapping-cell div:last-child {
  margin-bottom: 0;
}

.export-block {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed var(--border);
}

.export-block:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.export-block h3 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem;
}

.export-viz {
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

.icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.icon-row .diagram-icon {
  width: 160px;
  height: 56px;
  font-size: 0.82rem;
}

.viz-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.legend-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  background: var(--bg-soft);
  position: sticky;
  top: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.legend-panel h4 {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.legend-panel h4:first-child { margin-top: 0; }

.legend-item {
  margin-bottom: 0.4rem;
}

.legend-item .diagram-icon {
  width: 100%;
  height: auto;
  min-height: 36px;
  font-size: 0.7rem;
}

.clusters-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow: auto;
  max-height: 70vh;
  scrollbar-gutter: stable;
}

.cluster-row {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--border);
}

.cluster-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.cluster-canvas {
  position: relative;
}

.cluster-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Shared box look for parts/steps used in legend + cluster diagrams */
.diagram-icon {
  font-size: 0.78rem;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.3rem;
  box-sizing: border-box;
}

.diagram-icon b {
  color: var(--primary);
  display: block;
}

.diagram-icon span {
  display: block;
  overflow: visible;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.part-icon {
  background: #eaf2f8;
  border: 2px solid var(--primary);
  border-radius: 6px;
}

.step-icon {
  background: #dbe7f7;
  border: 2px solid #2c4f7c;
  border-radius: 6px;
}

.step-icon b { color: #2c4f7c; }

.constraint-oval {
  background: #fdf0e0;
  border: 2px solid #c87f1e;
  border-radius: 999px;
  color: #6b4400;
  overflow: visible;
}
