:root {
  color-scheme: light;
  --ink: #26211d;
  --muted: #706861;
  --line: #ded6cc;
  --paper: #fffaf2;
  --panel: #ffffff;
  --mint: #0f9f8f;
  --mint-dark: #08786d;
  --coral: #ff6f61;
  --lemon: #f9c846;
  --sky: #72a8ff;
  --shadow: 0 14px 34px rgba(52, 45, 36, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 159, 143, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 111, 97, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Sans", Meiryo, system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(255, 250, 242, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.brand strong {
  display: block;
  font-size: 22px;
  letter-spacing: 0;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--coral);
  color: white;
  font-weight: 800;
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.tab,
.ghost,
.primary,
.tagger button,
.compose-form menu button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  min-height: 40px;
  padding: 0 14px;
}

.tab.is-active,
.primary {
  border-color: var(--mint);
  background: var(--mint);
  color: white;
  font-weight: 700;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-box input[type="text"],
.user-box input:not([type]) {
  width: 180px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.8;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px 22px 56px;
}

.map-switcher {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.map-switcher h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 54px);
  letter-spacing: 0;
}

.map-switcher p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.map-actions {
  display: flex;
  gap: 10px;
}

.map-actions select {
  min-width: 240px;
}

.map-view {
  overflow: auto;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.flow-board {
  position: relative;
  min-width: 1120px;
  min-height: 640px;
  padding: 34px;
}

.flow-line {
  position: absolute;
  height: 3px;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--mint), var(--sky));
  border-radius: 999px;
}

.post-card {
  position: absolute;
  width: 260px;
  height: 232px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 2px solid #3a332e;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
}

.post-card:hover,
.branch-card:hover {
  transform: translateY(-2px);
}

.post-card.is-read {
  border-color: var(--mint);
}

.card-topline,
.reader-meta,
.card-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.check {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: white;
  font-weight: 800;
}

.excerpt {
  margin: 0;
  line-height: 1.65;
  font-size: 15px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  background: #fff1bd;
  color: #5d4300;
  font-size: 12px;
}

.reader-view {
  display: grid;
  gap: 18px;
}

.back-button {
  justify-self: start;
}

.reader-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 38px);
  box-shadow: var(--shadow);
}

.reader-panel h2 {
  margin: 12px 0 16px;
  font-size: clamp(24px, 4vw, 40px);
}

.reader-panel p {
  white-space: pre-wrap;
  line-height: 2.05;
  font-size: 18px;
}

.tagger {
  display: grid;
  gap: 8px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.tagger-row,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tagger-row select {
  flex: 1;
}

.branch-section {
  padding: 8px 0 40px;
}

.section-title h3 {
  margin: 0;
  font-size: 22px;
}

.branch-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.branch-card {
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
  text-align: left;
  box-shadow: 0 8px 18px rgba(52, 45, 36, 0.08);
}

dialog {
  width: min(720px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(38, 33, 29, 0.36);
}

.compose-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-head h2 {
  margin: 0;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 24px;
}

.compose-form label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.compose-form label input,
.compose-form label textarea {
  font-weight: 400;
}

.counter,
.selection-tools,
.auto-card-note,
.compose-form details,
.compose-form small {
  color: var(--muted);
  font-size: 13px;
}

.selection-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terms {
  grid-template-columns: auto 1fr;
  align-items: start;
  font-weight: 400 !important;
  line-height: 1.6;
}

.context-preview {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7e5;
}

.context-preview h3 {
  margin: 0;
  font-size: 15px;
}

.context-preview p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--ink);
  line-height: 1.8;
}

.compose-form menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

@media (max-width: 760px) {
  .topbar,
  .map-switcher,
  .tagger-row,
  .section-title {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .mode-tabs,
  .user-box,
  .map-actions {
    justify-content: stretch;
  }

  .user-box,
  .map-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .user-box input[type="text"],
  .user-box input:not([type]) {
    width: 100%;
  }

  .flow-board {
    min-width: 860px;
  }
}
