@import url("https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Work+Sans:wght@300;400;500;600;700&display=swap");

:root {
  --bg: #f4efe6;
  --card: #ffffff;
  --ink: #1f1f1f;
  --muted: #5c5b57;
  --accent: #0f6d6a;
  --accent-dark: #0b4f4d;
  --line: rgba(15, 109, 106, 0.2);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fffdf8 0%, #f4efe6 55%, #efe3d4 100%);
  color: var(--ink);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-family: "DM Serif Display", serif;
  font-size: 28px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.brand h1 {
  font-family: "DM Serif Display", serif;
  font-size: 28px;
  margin: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.control {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 6px;
}

select,
input,
textarea {
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #fff;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 109, 106, 0.2);
}

button.ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost:hover {
  box-shadow: none;
  background: rgba(15, 109, 106, 0.08);
}

.main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 24px 32px 40px;
}

.sidebar {
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  height: fit-content;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 18px;
}

#tetelList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#tetelList li {
  display: block;
}

.tetel-title {
  width: 100%;
  text-align: left;
  background: rgba(15, 109, 106, 0.08);
  color: var(--accent-dark);
  font-weight: 600;
  border: 1px solid transparent;
}

.tetel-title.active {
  background: var(--accent);
  color: white;
}

.tetel-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tetel-subtitle-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  background: rgba(15, 109, 106, 0.04);
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

.tetel-subtitle-btn.active {
  background: var(--accent);
  color: white;
}

.content {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: var(--shadow);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.content-header h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.content-header p {
  margin: 0;
  color: var(--muted);
}

.part-toggle {
  display: flex;
  gap: 8px;
}

.part-toggle button {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

.part-toggle button.active {
  background: var(--accent);
  color: white;
}

.content-body {
  margin-top: 20px;
  line-height: 1.6;
}

.level {
  margin-bottom: 16px;
}

.level-1 {
  margin-left: 0;
}

.level-2 {
  margin-left: 12px;
}

.level-3 {
  margin-left: 24px;
}

.level-4 {
  margin-left: 36px;
}

.level-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.level-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.level-buttons button {
  padding: 6px 12px;
  font-size: 12px;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

.level-buttons button.active {
  background: var(--accent);
  color: white;
}

.content-body h1,
.content-body h2,
.content-body h3 {
  font-family: "DM Serif Display", serif;
}

.content-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

.empty {
  padding: 24px;
  background: rgba(15, 109, 106, 0.06);
  border-radius: 14px;
  color: var(--muted);
}

.suggestion {
  margin-top: 24px;
  padding: 20px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  background: rgba(15, 109, 106, 0.05);
}

.suggestion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.revision-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.revision-tools select {
  min-width: 180px;
}

.suggestion textarea {
  width: 100%;
  margin-top: 8px;
}

.suggestion-actions {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.error {
  color: #b00020;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal-card {
  background: white;
  padding: 24px;
  border-radius: 16px;
  width: min(360px, 90vw);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .main {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

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