﻿:root {
  --paper: #fcfbf8;
  --ink: #1f1f1f;
  --muted: #67625a;
  --edge: #d7d0c4;
  --panel: #f4efe7;
  --insert: #1f5fb6;
  --delete: #a32020;
  --target: #f1d98a;
  --focus: #0f62fe;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, #fffdf8 0%, #f7f2e8 55%, #f0e8db 100%);
}

body {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--edge);
  background: #f9f5eecc;
  backdrop-filter: blur(8px);
}

.toolbar h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

button,
.toggle {
  border: 1px solid #b5ac9d;
  background: #fff;
  color: #2a2926;
  border-radius: 0.45rem;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.92rem;
}

button {
  cursor: pointer;
}

button:hover,
.toggle:hover {
  background: #f7f2e8;
}

button:focus-visible,
.toggle:focus-within,
.action-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "act amend";
  gap: 1rem;
  padding: 1rem;
  min-height: 0;
}

.panel {
  border: 1px solid var(--edge);
  border-radius: 0.7rem;
  background: linear-gradient(180deg, #f6f1e8 0%, #f2eadf 100%);
  box-shadow: 0 8px 22px #8071521f;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.act-panel {
  grid-area: act;
}

.amendment-panel {
  grid-area: amend;
}

.panel h2 {
  margin: 0;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #d8d1c7;
  font-size: 0.98rem;
  letter-spacing: 0.045em;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #e0d9cd;
}

.doc {
  overflow: auto;
  padding: 1rem 1.2rem 1.4rem;
  line-height: 1.45;
  background: var(--paper);
  margin: 0.8rem;
  border: 1px solid #dfd7c8;
  border-radius: 0.45rem;
}

.doc-title {
  font-size: 1.12rem;
  margin-top: 0;
}

.doc-meta {
  color: var(--muted);
}

.parse-box {
  margin: 0.8rem 0.8rem 0;
  padding: 0.75rem;
  border: 1px solid #d8cfbf;
  border-radius: 0.45rem;
  background: #fff8ec;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.parse-status {
  font-size: 0.86rem;
  color: var(--muted);
}

.parse-status.loading::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.4rem;
  border: 2px solid #c2b9a7;
  border-top-color: #7d6f49;
  border-radius: 50%;
  vertical-align: -0.12rem;
  animation: spin 700ms linear infinite;
}

.indent {
  padding-left: 1.3rem;
}

.indent2 {
  padding-left: 2.3rem;
}

.actions {
  border-top: 1px solid #e2dbd1;
  padding: 0.8rem;
  min-height: 14rem;
  overflow: auto;
}

.actions h3 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
}

.action-card {
  border: 1px solid #d9d1c2;
  background: #fffaf1;
  border-radius: 0.5rem;
  padding: 0.65rem;
  margin-bottom: 0.55rem;
}

.action-card.selected {
  border-color: #9f8e63;
  box-shadow: 0 0 0 1px #bba773;
}

.action-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.action-id {
  font-weight: 600;
  font-size: 0.9rem;
}

.apply-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
}

.apply-btn[aria-pressed="true"] {
  border-color: #23539c;
  background: #edf4ff;
  color: #1f5fb6;
}

.target-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0;
}

.action-details {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px dashed #cfc5b3;
  font-size: 0.82rem;
}

.action-details p {
  margin: 0.22rem 0;
}

.ins {
  color: var(--insert);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  animation: fadeInsert 280ms ease;
}

.del {
  color: var(--delete);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.target-anchor {
  display: inline-block;
  width: 0.18rem;
  height: 1em;
  vertical-align: text-bottom;
}

.target-hot,
.target-locked {
  border-radius: 0.28rem;
  box-shadow: 0 0 0 2px #e5cb83;
  background: #fff4d6;
}

.target-hot {
  animation: pulseTarget 620ms ease;
}

@keyframes pulseTarget {
  0% {
    box-shadow: 0 0 0 0 #cfb46c99;
  }
  100% {
    box-shadow: 0 0 0 9px #cfb46c00;
  }
}

@keyframes fadeInsert {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "amend"
      "act";
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
