.tool-view {
  padding: 42px 0 64px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 26px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 160ms ease;
}

.back-link:hover {
  color: var(--mint-dark);
}

.tool-header {
  display: flex;
  margin-bottom: 30px;
  gap: 18px;
  align-items: center;
}

.tool-header .tool-icon {
  width: 60px;
  height: 60px;
  margin: 0;
}

.tool-header h1 {
  margin-bottom: 6px;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.tool-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.toolbar {
  display: flex;
  margin-bottom: 14px;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-wrap {
  position: relative;
}

.editor-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fbfdfc;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.editor-shell:focus-within {
  border-color: rgba(104, 189, 156, 0.72);
  box-shadow: 0 0 0 4px rgba(104, 189, 156, 0.08);
}

.editor-shell:has(.editor.invalid) {
  border-color: rgba(207, 93, 93, 0.68);
  box-shadow: 0 0 0 4px rgba(207, 93, 93, 0.08);
}

.line-numbers {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  left: 0;
  width: 54px;
  overflow: hidden;
  padding-top: 24px;
  border-right: 1px solid #edf2f0;
  background: #f6f9f7;
  color: #9aa9a4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 24.08px;
  text-align: right;
  user-select: none;
}

.line-numbers div div {
  position: relative;
  display: flex;
  height: 24.08px;
  padding-right: 13px;
  align-items: center;
  justify-content: flex-end;
}

.fold-toggle {
  position: absolute;
  left: 3px;
  display: grid;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #6e8d82;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 17px;
  line-height: 1;
  place-items: center;
}

.fold-toggle:hover {
  background: #e4f1ec;
  color: var(--mint-dark);
}

.hierarchy-guides {
  position: absolute;
  z-index: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 78px;
  overflow: hidden;
  padding-top: 24px;
  pointer-events: none;
}

.hierarchy-line {
  position: relative;
  width: max-content;
  min-width: 100%;
  height: 24.08px;
}

.hierarchy-line span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc((var(--guide-level) - 1) * 16.86px + 1px);
  border-left: 1px solid rgba(104, 189, 156, 0.24);
}

.editor {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  min-height: 480px;
  resize: vertical;
  padding: 24px 24px 24px 78px;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--mint-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.72;
  tab-size: 2;
  white-space: pre;
}

.editor::placeholder {
  color: #8a9a95;
}

.editor::selection {
  background: rgba(104, 189, 156, 0.24);
}

.json-highlight {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 24px 24px 24px 78px;
  color: #53645f;
  pointer-events: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.72;
  tab-size: 2;
  white-space: pre;
}

.json-key {
  color: #247b67;
}

.json-string {
  color: #b4632d;
}

.json-number {
  color: #3f6fc1;
}

.json-boolean {
  color: #8a55b8;
}

.json-null {
  color: #a24f68;
  font-style: italic;
}

.editor:focus,
.editor.invalid {
  outline: none;
}

.editor[readonly] {
  cursor: default;
}

.editor-meta {
  display: flex;
  padding: 12px 4px 1px;
  color: var(--muted);
  font-size: 12px;
  justify-content: space-between;
}

.status-error {
  color: var(--danger);
}

/* 历史记录功能样式 */
.json-workspace {
  display: flex;
  gap: 18px;
  align-items: stretch;
}

.workspace-main {
  flex: 1;
  min-width: 0;
}

.history-toggle {
  position: relative;
}

.history-count {
  display: inline-flex;
  margin-left: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--mint-soft);
  color: var(--mint-dark);
  font-size: 10px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.history-panel {
  display: flex;
  flex: 0 0 320px;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.history-panel[hidden] {
  display: none;
}

.history-panel-head {
  display: flex;
  margin-bottom: 14px;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.history-panel-head h2 {
  margin: 0 0 3px;
  font-size: 16px;
}

.history-panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.history-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.history-close:hover {
  background: var(--mint-soft);
  color: var(--mint-dark);
}

.history-list {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  max-height: 460px;
}

.history-empty {
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.history-item {
  display: flex;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfc;
  gap: 8px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.history-item:hover {
  border-color: rgba(104, 189, 156, 0.5);
  background: var(--mint-soft);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-item-head {
  display: flex;
  margin-bottom: 6px;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.history-tag {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
}

.history-tag-format {
  background: #e8f3ee;
  color: var(--mint-dark);
}

.history-tag-minify {
  background: #e7eefc;
  color: #3f6fc1;
}

.history-tag-unescape {
  background: #fbecdf;
  color: #b4632d;
}

.history-tag-edit {
  background: #f1ede7;
  color: #8a7a68;
}

.history-time {
  color: var(--muted);
  font-size: 10px;
}

.history-chars {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}

.history-preview {
  margin: 0;
  overflow: hidden;
  color: #4a5d58;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-all;
}

.history-delete {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #b6c2be;
  cursor: pointer;
  font-size: 13px;
}

.history-delete:hover {
  background: rgba(207, 93, 93, 0.12);
  color: var(--danger);
}

.history-panel-foot {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.history-panel-foot .button {
  width: 100%;
}

.history-panel-foot .button.danger:hover {
  border-color: rgba(207, 93, 93, 0.5);
  color: var(--danger);
  background: rgba(207, 93, 93, 0.08);
}

@media (max-width: 900px) {
  .json-workspace {
    flex-direction: column;
  }

  .history-panel {
    flex-basis: auto;
  }

  .history-list {
    max-height: 320px;
  }
}
