:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-muted: #eef3f1;
  --text: #202426;
  --muted: #607078;
  --line: #d6dde3;
  --accent: #176b5b;
  --accent-strong: #0f594b;
  --accent-soft: #dceee9;
  --blue: #3157b8;
  --blue-soft: #e2e9fb;
  --warn: #b66c1c;
  --danger: #ad3030;
  --shadow: 0 16px 38px rgba(28, 38, 44, 0.08);
  font-family:
    "Segoe UI",
    "Noto Sans JP",
    system-ui,
    -apple-system,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(23, 107, 91, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(23, 107, 91, 0.18);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.38rem;
  line-height: 1.15;
}

h2 {
  font-size: 1rem;
  line-height: 1.25;
}

.brand p,
.panel-head p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.top-actions,
.panel-head,
.item-tools,
.segmented {
  display: flex;
  align-items: center;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.segmented {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segment {
  min-width: 66px;
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  background: var(--accent);
  color: #ffffff;
}

.icon-button,
.tool-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
}

.icon-button:hover,
.tool-button:hover,
.secondary-action:hover,
.drag-handle:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.icon-button.danger:hover,
.tool-button.remove:hover {
  border-color: rgba(173, 48, 48, 0.5);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  align-items: start;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
}

.editor-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-panel {
  padding: 16px;
}

.preview-panel {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.share-panel {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.markdown-head {
  margin-top: 0;
}

.qr-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

#qrCanvas {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.qr-fields {
  min-width: 0;
}

.qr-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 13px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  border: 1px solid var(--blue);
  background: #ffffff;
  color: var(--blue);
}

.project-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.icon-button.text-action {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  font-size: 0.78rem;
}

input,
select {
  min-height: 44px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 87, 184, 0.14);
}

.item-list {
  display: grid;
  gap: 10px;
}

.prompt-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.prompt-item.is-dragging {
  opacity: 0.45;
}

.prompt-item.is-over-before,
.prompt-item.is-over-after {
  border-color: var(--warn);
}

.prompt-item.is-over-before::before,
.prompt-item.is-over-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 999px;
  background: var(--warn);
}

.prompt-item.is-over-before::before {
  top: -2px;
}

.prompt-item.is-over-after::after {
  bottom: -2px;
}

.item-main {
  display: grid;
  grid-template-columns: 38px 46px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.drag-handle {
  width: 38px;
  height: 44px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.is-reordering {
  overscroll-behavior: contain;
}

.priority-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 900;
}

.item-fields {
  min-width: 0;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.include-toggle {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.include-toggle span {
  margin: 0;
  color: inherit;
  font-size: 0.82rem;
}

.include-toggle input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.content-field {
  display: block;
  margin-top: 10px;
}

.item-tools {
  align-content: start;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 82px;
  gap: 6px;
}

#markdownOutput {
  min-height: calc(100vh - 420px);
  max-height: calc(100vh - 420px);
  resize: vertical;
  font-family:
    "Cascadia Code",
    Consolas,
    "Courier New",
    monospace;
  font-size: 0.88rem;
  white-space: pre;
}

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

  .preview-panel {
    position: static;
  }

  #markdownOutput {
    min-height: 420px;
    max-height: none;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  h1 {
    font-size: 1.2rem;
  }

  .project-fields,
  .qr-layout,
  .prompt-item,
  .item-main,
  .item-row {
    grid-template-columns: 1fr;
  }

  #qrCanvas {
    justify-self: center;
  }

  .item-main {
    gap: 8px;
  }

  .drag-handle,
  .priority-badge {
    width: 100%;
  }

  .item-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .tool-button {
    width: 42px;
  }
}
