:root {
  color-scheme: light dark;
  --bg-page: #f5f1e8;
  --bg-surface: rgba(255, 255, 255, 0.78);
  --bg-surface-strong: rgba(255, 255, 255, 0.9);
  --bg-input: rgba(255, 255, 255, 0.68);
  --text-main: #1a2440;
  --text-muted: #44506c;
  --primary: #1f3563;
  --primary-hover: #172a50;
  --accent: #1d8b88;
  --accent-soft: rgba(29, 139, 136, 0.14);
  --danger: #a24646;
  --danger-soft: rgba(162, 70, 70, 0.12);
  --border: rgba(31, 53, 99, 0.18);
  --shadow: 0 16px 38px rgba(26, 36, 64, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #0d1426;
    --bg-surface: rgba(24, 34, 58, 0.74);
    --bg-surface-strong: rgba(24, 34, 58, 0.9);
    --bg-input: rgba(10, 17, 33, 0.68);
    --text-main: #edf1fb;
    --text-muted: #b3c1dd;
    --primary: #8aa4db;
    --primary-hover: #a5b9e4;
    --accent: #54c2bb;
    --accent-soft: rgba(84, 194, 187, 0.2);
    --danger: #e59393;
    --danger-soft: rgba(229, 147, 147, 0.16);
    --border: rgba(179, 193, 221, 0.24);
    --shadow: 0 20px 45px rgba(0, 0, 0, 0.42);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 16% 12%, rgba(29, 139, 136, 0.12), transparent 38%), var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  padding: 20px;
}

.tool-shell {
  max-width: 1240px;
  margin: 0 auto;
}

.tool-header {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 24px;
  margin-bottom: 18px;
}

.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .76rem; color: var(--accent); font-weight: 700; margin: 0 0 10px; }
.tool-header h1 { margin: 0; font-size: clamp(1.45rem, 1.1rem + 1.5vw, 2rem); }
.subtitle { margin: 8px 0 16px; color: var(--text-muted); max-width: 72ch; }
.dashboard-link { color: var(--primary); text-decoration: none; font-weight: 700; }
.dashboard-link:hover { text-decoration: underline; }

.container {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(360px, 1.25fr);
  gap: 18px;
}

.left-column,
.right-column {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 18px;
  min-width: 0;
}

label { display:block; margin: 10px 0 6px; color: var(--text-muted); font-weight: 600; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  color: var(--text-main);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.title-list {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-input);
  overflow-y: auto;
  max-height: 58vh;
  min-height: 280px;
  padding: 8px;
}
.title-list-item { padding: 10px 12px; border-radius: 10px; cursor:pointer; border: 1px solid transparent; }
.title-list-item:hover { background: var(--accent-soft); }
.title-list-item.selected,
.title-list-item.active { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

.button-container { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:10px; margin-top: 14px; }
button { border-radius: 12px; padding: 10px 12px; font: inherit; font-weight: 600; cursor:pointer; transition: .2s ease; border:1px solid transparent; }
button:hover { transform: translateY(-1px); }

#copyDiagnosisBtn, #copyManagementBtn, #copyProcedureBtn, #copyConsentBtn {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
#copyDiagnosisBtn:hover, #copyManagementBtn:hover, #copyProcedureBtn:hover, #copyConsentBtn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

#updateJsonBtn { background: transparent; color: var(--accent); border-color: var(--accent); }
#updateJsonBtn:hover { background: var(--accent-soft); }

#newEntryBtn { background: transparent; color: var(--text-main); border-color: var(--border); }
#newEntryBtn:hover { background: rgba(125, 142, 178, 0.14); }

#deleteJsonBtn { background: transparent; color: var(--danger); border-color: var(--danger); }
#deleteJsonBtn:hover { background: var(--danger-soft); }

@media (max-width: 900px) {
  body { padding: 14px; }
  .container { grid-template-columns: 1fr; }
  .title-list { max-height: 40vh; min-height: 220px; }
}

@media (max-width: 640px) {
  .tool-header, .left-column, .right-column { border-radius: 16px; padding: 14px; }
  .button-container { grid-template-columns: 1fr; }
  button { width: 100%; }
}
