* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #18202a;
  --muted: #607080;
  --line: #d7dee8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f3ee;
  --danger: #b42318;
  --danger-dark: #8f1d14;
  --focus: rgba(15, 118, 110, 0.18);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
select,
input {
  font: inherit;
}

button,
.button-link {
  min-height: 44px;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  transition: background 0.2s, transform 0.2s;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  text-decoration: none;
}

button:disabled {
  background: #a8b3bd;
  cursor: not-allowed;
  transform: none;
}

button.delete {
  background: var(--danger);
}

button.delete:hover {
  background: var(--danger-dark);
}

button.delete:disabled {
  background: #c8b6b3;
}

select,
input,
.editor {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

select {
  padding: 11px 12px;
  cursor: pointer;
}

input {
  padding: 13px 14px;
  font-size: 20px;
  font-weight: 700;
}

input:focus,
.editor:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  padding: 24px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header.compact {
  padding-bottom: 20px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--accent-dark);
  font-weight: 700;
}

.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
}

.site-heading {
  max-width: 820px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #4f46e5;
  font-size: 13px;
  font-weight: 700;
}

.site-heading h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.25;
}

.site-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.home-main,
.content-main,
.converter-main {
  width: min(980px, calc(100% - 32px));
  margin: 24px auto;
}

.home-main,
.converter-main {
  display: grid;
  gap: 18px;
}

.tool-list {
  display: grid;
  gap: 14px;
}

.section-heading h2,
.panel h2,
.text-section h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.section-heading p,
.text-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.tool-card,
.panel,
.result-card,
.text-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.tool-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.tool-card h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.site-footer {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 28px;
  color: var(--muted);
}

.memo-page {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
}

.memo-page .site-header {
  grid-column: 1 / -1;
}

.memo-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px;
  overflow-y: auto;
}

.memo-main {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface-soft);
}

.app-title {
  margin: 0 0 18px;
  font-size: 24px;
}

.memo-sidebar h3 {
  margin: 22px 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.side-actions,
.toolbar,
.actions,
.top-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-actions {
  flex-direction: column;
  align-items: stretch;
}

.top-row {
  align-items: stretch;
}

.top-row input {
  flex: 1;
}

.top-row select {
  width: 180px;
}

.folder,
.note {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 8px;
  background: #f1f5f9;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.folder:hover,
.note:hover {
  background: #e7eef6;
}

.folder.active,
.note.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 700;
}

.note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-folder-select {
  width: 110px;
  flex-shrink: 0;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.editor {
  flex: 1;
  min-height: 400px;
  padding: 14px;
  font-size: 16px;
  line-height: 1.8;
  overflow-y: auto;
}

.editor:empty::before {
  content: attr(data-placeholder);
  color: #93a0ad;
}

.editor img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.counter,
#status,
.status {
  color: var(--muted);
  font-size: 14px;
}

.counter {
  margin: 0;
  text-align: right;
}

.converter-panel {
  display: grid;
  gap: 14px;
}

.drop-area {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 2px dashed #8abbb5;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
  padding: 24px;
  transition: background 0.2s, border-color 0.2s;
}

.drop-area.dragover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.drop-area strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.drop-area span {
  color: var(--muted);
  line-height: 1.7;
}

input[type="file"] {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.status {
  margin: 0;
  line-height: 1.7;
}

.results {
  display: grid;
  gap: 14px;
}

.result-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.result-card img {
  width: 160px;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.result-card h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.download-all {
  justify-self: start;
}

canvas {
  display: none;
}

.content-main {
  display: grid;
  gap: 14px;
}

.text-section p + p {
  margin-top: 10px;
}

@media (max-width: 760px) {
  .site-header {
    padding: 20px 16px;
  }

  .site-heading h1 {
    font-size: 26px;
  }

  .tool-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .memo-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 300px 1fr;
  }

  .memo-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .memo-main {
    padding: 16px;
  }

  .top-row,
  .toolbar,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .top-row select,
  .note-folder-select {
    width: 100%;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .result-card {
    grid-template-columns: 1fr;
  }

  .result-card img {
    width: 100%;
  }
}
