:root {
  color-scheme: light;
  --ink: #1d1a16;
  --muted: #5e584f;
  --line: #e4dccd;
  --paper: #f3f0e8;
  --card: #fffdf8;
  --accent: #1f4b6e;
  --accent-ink: #ffffff;
  --danger: #8c2f2f;
  --danger-bg: #f8e8e4;
  --ok: #1d6b45;
  --ok-bg: #e5f3eb;
  --shadow: 0 1px 0 rgba(29, 26, 22, 0.04);
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

.app {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 28px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
}

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

h1, h2 { margin: 0; font-weight: 650; }

h1 { font-size: 18px; letter-spacing: 0.01em; }

h2 { font-size: 13px; color: var(--muted); }

.lead, .hint, .entry-note, .footer {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.lead { margin-top: 8px; }

.entries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.entry {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.entry.is-over,
.entry.is-active {
  border-color: var(--accent);
  background: #f4f8fb;
}

.entry h2 {
  font-size: 16px;
  color: var(--ink);
}

.entry-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.entry-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.primary {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.primary:disabled {
  background: #e7e2d8;
  color: #8a847a;
  cursor: not-allowed;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.text-button,
.action,
.download,
.primary {
  font: inherit;
}

.text-button,
.action,
.download {
  cursor: pointer;
}

.text-button {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.file-list {
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  max-height: 160px;
  overflow: auto;
}

.file-list li {
  font-size: 12px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action,
.download {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 8px 12px;
}

.action {
  background: var(--accent);
  color: var(--accent-ink);
}

.action:disabled {
  background: #e7e2d8;
  color: #8a847a;
  cursor: not-allowed;
}

.download {
  background: var(--ok);
  color: white;
}

.status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.status.is-error { background: var(--danger-bg); color: var(--danger); }
.status.is-ok { background: var(--ok-bg); color: var(--ok); }
.status.is-busy { background: var(--card); color: var(--ink); border: 1px solid var(--line); }

.footer {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.is-busy { cursor: progress; }

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.save {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.save-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}

.save-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-name {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid #b7b0a4;
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.save-name:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.save-ext {
  font-size: 14px;
  color: var(--muted);
}

.save[hidden] { display: none; }
