:root {
  --ink: #17202a;
  --muted: #5f6b7a;
  --paper: #fbfaf7;
  --line: #d8d6cd;
  --accent: #146c63;
  --accent-dark: #0d514a;
  --tag: #e8f2ee;
  --note: #fff7d7;
  --shadow: 0 18px 60px rgba(35, 38, 42, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(20, 108, 99, 0.13), transparent 34%),
    linear-gradient(320deg, rgba(177, 78, 45, 0.12), transparent 40%),
    #ece9df;
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

.shell {
  width: min(980px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 32px 0;
}

.paper-panel {
  background: var(--paper);
  border: 1px solid rgba(88, 82, 66, 0.2);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 56px);
}

.topbar,
.memo-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.history-nav {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 10px;
  margin: 28px 0 0;
  align-items: center;
}

.history-nav select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

.compact-button {
  min-height: 44px;
  padding: 10px 14px;
}

.label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.date-label {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 24px;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--tag);
}

h1 {
  margin: 34px 0 10px;
  font-size: clamp(30px, 4.8vw, 56px);
  line-height: 1.18;
  letter-spacing: 0;
}

.paper-number {
  margin: 0 0 18px;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 700;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.keywords span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--tag);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 28px 0 34px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

button.secondary-button {
  cursor: pointer;
}

button.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.section-block {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 24px;
}

h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

#summary {
  margin: 0;
  color: #2d3642;
  font-size: 16px;
  line-height: 1.9;
}

.memo-head span {
  color: var(--muted);
  font-size: 13px;
}

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid #d7ca94;
  border-radius: 8px;
  background: var(--note);
  color: var(--ink);
  padding: 16px;
  font: inherit;
  line-height: 1.7;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.16);
}

.log-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-color: var(--accent) #ede9dc;
  scrollbar-width: thin;
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.tag-filter button,
.log-tags button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tag-filter button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tag-filter-empty {
  color: var(--muted);
  font-size: 13px;
}

.log-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.log-tags button {
  min-height: 26px;
  padding: 4px 8px;
  background: var(--tag);
}

.sync-state {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.log-empty,
.log-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.log-empty {
  color: var(--muted);
}

.log-item {
  display: grid;
  gap: 6px;
}

.log-meta {
  color: var(--muted);
  font-size: 13px;
}

.log-title {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.5;
}

.log-memo {
  color: #2d3642;
  font-size: 14px;
  line-height: 1.7;
}

.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 980px);
    padding: 10px 0;
  }

  .paper-panel {
    padding: 22px;
  }

  h1 {
    margin-top: 26px;
    font-size: 30px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .history-nav {
    grid-template-columns: 1fr;
  }

  .log-list {
    max-height: 360px;
  }
}
