/* Shared styles for tool pages (json, paste, ...) */

.tool-workspace [hidden] {
  display: none !important;
}

/* Intro */

.tool-intro {
  padding-top: 56px;
  padding-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tool-eyebrow {
  font-size: 14px;
}

.tool-title {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.tool-lead {
  max-width: 40rem;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--color-muted);
}

/* Workspace */

.tool-workspace {
  padding-bottom: 72px;
}

.tool-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

x-tab-bar {
  flex: 1 1 0;
  min-width: 0;
  display: block;
}

.tab-list {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-add,
.tab {
  flex: none;
  border: 1px solid var(--color-border);
  border-bottom: 0;
  border-radius: var(--radius-small) var(--radius-small) 0 0;
  background: var(--color-band);
}

.tab-add {
  width: 36px;
  height: 38px;
  color: var(--color-muted);
  font-size: 18px;
  cursor: pointer;
}

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

.tab {
  display: flex;
  align-items: center;
  height: 38px;
  border-top: 2px solid transparent;
}

.tab.is-active {
  height: 42px;
  background: var(--color-surface);
  border-top-color: var(--color-copper);
}

.tab-label {
  height: 100%;
  padding: 0 4px 0 14px;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.tab.is-active .tab-label {
  color: var(--color-text);
  cursor: text;
}

.tab-input {
  margin: 0 4px 0 8px;
  padding: 4px 6px;
  border: 1px solid var(--color-teal);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 13px;
}

.tab-close {
  width: 28px;
  height: 28px;
  margin-right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}

.tab-close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.tool-actions {
  flex: none;
  display: flex;
  gap: 8px;
  padding-bottom: 6px;
}

.tool-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-small);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
}

.tool-button:hover {
  border-color: var(--color-teal);
}

.tool-button.tool-button-done,
.tool-button.tool-button-done:hover {
  background: var(--color-done);
  border-color: var(--color-done);
  color: var(--color-on-done);
}

.tool-button-primary {
  background: var(--color-copper);
  border-color: var(--color-copper);
  color: var(--color-on-copper);
}

/* Editor and button-state colors (done = mediumseagreen) */

:root,
:root[data-theme="dark"] {
  --color-done: #3CB371;
  --color-on-done: #0D1316;
  --color-active-line: rgba(147, 167, 176, 0.07);
  --color-selection: rgba(91, 168, 188, 0.30);
  --color-search-match: rgba(229, 140, 63, 0.35);
}

:root[data-theme="light"] {
  --color-done: #3CB371;
  --color-on-done: #0D1316;
  --color-active-line: #ECEEFA;
  --color-selection: rgba(35, 103, 122, 0.22);
  --color-search-match: rgba(168, 88, 22, 0.25);
}

/* Editor */

x-code-editor {
  display: block;
  height: clamp(420px, 65vh, 900px);
  border: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-large) var(--radius-large);
  background: var(--color-surface);
  overflow: hidden;
}

x-code-editor.is-standalone {
  border-radius: var(--radius-large);
}

x-code-editor:focus-within {
  border-color: var(--color-teal);
}

x-code-editor .cm-editor {
  height: 100%;
  color: var(--color-text);
  background: transparent;
  font-size: 13px;
}

x-code-editor .cm-editor.cm-focused {
  outline: none;
}

x-code-editor .cm-editor .cm-scroller {
  font-family: var(--font-mono);
  line-height: 1.6;
  /* JetBrains Mono turns <!-- --> and similar into arrows; code must show exactly what is typed. */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

x-code-editor .cm-editor .cm-content {
  padding: 12px 0;
  caret-color: var(--color-text);
}

x-code-editor .cm-editor .cm-cursor {
  border-left-color: var(--color-text);
}

x-code-editor .cm-editor .cm-gutters {
  background: var(--color-band);
  color: var(--color-muted);
  border-right: 1px solid var(--color-border);
}

x-code-editor .cm-editor .cm-lineNumbers .cm-gutterElement {
  padding: 0 8px 0 12px;
}

x-code-editor .cm-editor .cm-foldGutter .cm-gutterElement {
  padding: 0 6px 0 2px;
  cursor: pointer;
}

x-code-editor .cm-editor .cm-activeLine {
  background: var(--color-active-line);
}

x-code-editor .cm-editor .cm-activeLineGutter {
  background: var(--color-active-line);
  color: var(--color-text);
}

x-code-editor .cm-editor .cm-selectionBackground,
x-code-editor .cm-editor.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground,
x-code-editor .cm-editor .cm-content ::selection {
  background: var(--color-selection) !important;
}

x-code-editor .cm-editor .cm-matchingBracket {
  background: var(--color-selection);
  outline: 1px solid var(--color-muted);
}

x-code-editor .cm-editor .cm-placeholder {
  color: var(--color-muted);
}

x-code-editor .cm-editor .cm-foldPlaceholder {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  padding: 0 6px;
}

/* Search panel */

x-code-editor .cm-editor .cm-panels {
  background: var(--color-band);
  color: var(--color-text);
  border-color: var(--color-border);
}

x-code-editor .cm-editor .cm-panel.cm-search input,
x-code-editor .cm-editor .cm-panel.cm-search button {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

x-code-editor .cm-editor .cm-searchMatch {
  background: var(--color-search-match);
}

.editor-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--color-copper);
}

.editor-status::before {
  content: "! ";
}

/* Confirm dialog */

.confirm-dialog {
  max-width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface);
  color: var(--color-text);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.confirm-message {
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-buttons .tool-button {
  min-height: 44px;
}

@media (max-width: 600px) {
  .tool-intro {
    padding-top: 40px;
  }

  .tool-toolbar {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .tool-actions {
    justify-content: flex-end;
  }

  x-tab-bar {
    flex: none;
  }

  x-code-editor {
    height: 60vh;
  }
}
