:root {
  color-scheme: light;
  --ink: #26352e;
  --muted: #65716b;
  --paper: #f5f6f2;
  --line: #dfe4de;
  --accent: #ad4938;
  --green: #345746;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(circle at 8% 4%, #e4ebe0 0, transparent 32rem), var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
}
a { color: inherit; }
button, select, input { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button, select { min-height: 44px; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1080px, calc(100% - 40px));
  margin: 20px auto 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.brand { font-family: Georgia, "Times New Roman", serif; font-size: 1.5rem; font-weight: 700; letter-spacing: -.04em; text-decoration: none; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { background: #fff; color: var(--accent); }
main { width: min(1080px, calc(100% - 40px)); margin: 30px auto 0; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 3px; color: var(--accent); font-size: .65rem; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: .04em; line-height: 1.35; }
.title-dot { color: var(--accent); }
.intro { margin: 0 0 3px; color: var(--muted); font-size: .8rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.toolbar label { display: grid; gap: 4px; color: var(--muted); font-size: .7rem; font-weight: 700; }
select { width: 156px; padding: 8px 30px 8px 12px; border: 1px solid #cbd4ca; border-radius: 10px; background: #fff; color: var(--ink); font-size: .85rem; }
.photo-count { margin: 0 0 10px auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viewer { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 10px 35px #1a27220a; }
.photo-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  background: #e7ebe4;
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.photo-stage img { display: block; width: 100%; height: auto; min-height: 0; -webkit-user-drag: none; }
.photo-stage img.is-loading { visibility: hidden; }
.photo-stage.is-dragging { cursor: grabbing; }
.photo-stage.is-dragging img { will-change: transform; filter: drop-shadow(0 12px 18px #26352e24); }
.photo-stage.is-settling img { will-change: transform; }
.swipe-hint { position: absolute; top: 14px; right: 14px; max-width: calc(100% - 130px); padding: 9px 14px; border: 1px solid #ffffffb3; border-radius: 12px; background: #fffffff2; color: var(--green); font-size: .8rem; font-weight: 700; text-align: center; pointer-events: none; }
.swipe-hint.is-ready { border-color: var(--green); background: var(--green); color: #fff; }
.stage-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
#message-title { margin: 0; font-size: 1rem; font-weight: 700; }
#message-detail { max-width: 28em; margin: 8px 0 0; color: #536158; font-size: .8rem; }
#message-action { margin-top: 16px; padding: 8px 20px; border: 1px solid #9cafa0; border-radius: 10px; background: #fff; color: var(--green); font-weight: 700; }
.level-badge { position: absolute; top: 14px; left: 14px; padding: 7px 14px; border: 1px solid #ffffff6b; border-radius: 999px; background: #ffffffed; color: var(--green); font-size: .8rem; box-shadow: 0 2px 12px #17231b0f; pointer-events: none; }
.level-badge strong { margin-left: 5px; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.photo-caption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 16px; padding: 10px 16px; color: var(--muted); font-size: .7rem; }
#photo-filename { overflow-wrap: anywhere; }
.controls { display: grid; grid-template-columns: 1fr 1.5fr 1fr; align-items: center; gap: 12px; margin-top: 14px; }
.controls button { min-width: 0; min-height: 50px; padding: 10px 12px; border: 1px solid #cbd4ca; border-radius: 12px; font-size: .82rem; font-weight: 700; overflow-wrap: anywhere; }
.nav-button { background: #fff; color: var(--green); }
.nav-button:hover:enabled { background: #e9eee6; border-color: #a9b9aa; }
.level-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.level-controls .level-button { border-color: var(--green); background: var(--green); color: #fff; }
.level-button:hover:enabled { background: #264234; }
.controls button span { font-size: 1rem; }
.feedback { min-height: 1.6em; margin: 10px 0 6px; color: var(--accent); font-size: .76rem; text-align: center; overflow-wrap: anywhere; }
.gesture-help { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 24px; color: var(--muted); font-size: .75rem; }
.gesture-help span { overflow-wrap: anywhere; }
.gesture-help b { margin: 0 4px 0 8px; color: var(--green); font-size: .9rem; }
.session-note { margin: 8px 0 0; color: var(--muted); font-size: .7rem; text-align: center; }
.drag-help { margin: 7px 0 0; color: var(--muted); font-size: .7rem; text-align: center; }
.noscript { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: center; }
.site-footer { width: min(1080px, calc(100% - 40px)); margin: 28px auto 0; padding: 14px 0 max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: .7rem; text-align: center; }

input { width: 100%; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid #cbd4ca; border-radius: 10px; background: #fff; color: var(--ink); }
.class-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 10px; margin-bottom: 12px; }
.class-filters label, .setting-row label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: .75rem; }
.class-filters .class-empty-option { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.class-empty-option input { flex: 0 0 20px; width: 20px; height: 20px; min-height: 20px; margin: 0; padding: 0; accent-color: var(--green); }
.class-filters button, #open-settings, .settings-buttons button { min-height: 44px; padding: 8px 12px; border: 1px solid #cbd4ca; border-radius: 10px; background: #fff; color: var(--green); }
.photo-classes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .75rem; }
.photo-classes dt { color: var(--muted); font-weight: 700; }
.photo-classes dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #17231bb3; }
dialog h2 { margin: 0; }
dialog p { font-size: .85rem; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 18px 0; }
.setting-row select { width: 100%; }
.settings-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.settings-buttons button[type="submit"] { background: var(--green); color: #fff; }

@media (max-width: 600px) {
  .site-header { flex-direction: column; gap: 8px; width: calc(100% - 28px); margin-top: 10px; padding-bottom: 8px; }
  .brand { font-size: 1.25rem; }
  .site-nav { justify-content: center; }
  .site-nav a { min-height: 36px; padding-inline: 13px; font-size: .72rem; }
  main { width: calc(100% - 24px); margin-top: 16px; }
  .page-heading { margin-bottom: 14px; }
  .eyebrow { font-size: .58rem; }
  h1 { font-size: 1.7rem; }
  .intro { max-width: 9em; font-size: .67rem; }
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 10px; margin-bottom: 10px; }
  .toolbar label { min-width: 0; font-size: .65rem; }
  select { width: 100%; min-height: 44px; padding-left: 9px; font-size: 1rem; }
  .photo-count { grid-column: 1 / -1; margin: 0; font-size: .72rem; text-align: right; }
  .viewer { border-radius: 14px; }
  .photo-stage { min-height: 220px; }
  .level-badge { top: 10px; left: 10px; padding: 4px 11px; }
  .swipe-hint { top: 10px; right: 10px; max-width: calc(100% - 112px); padding: 7px 10px; font-size: .7rem; }
  .photo-caption { gap: 2px 8px; padding: 8px 11px; font-size: .6rem; }
  .controls { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
  .level-controls { grid-column: 1 / -1; grid-row: 1; gap: 8px; }
  .controls button { min-height: 46px; padding: 9px; }
  .feedback { margin-top: 7px; font-size: .7rem; }
  .gesture-help { gap: 3px 12px; font-size: .65rem; }
  .session-note { font-size: .62rem; }
  .class-filters { grid-template-columns: minmax(0, 1fr); }
  .photo-classes { gap: 8px; padding: 8px 11px; }
  .setting-row { grid-template-columns: minmax(0, 1fr); }
  input { font-size: 1rem; }
  .drag-help { font-size: .62rem; }
  .site-footer { margin-top: 18px; padding-top: 10px; }
}


.sync-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; margin: 0 0 12px; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.sync-bar button { min-height: 44px; padding: 8px 12px; border: 1px solid #9cafa0; border-radius: 10px; background: #fff; color: var(--green); }
#settings-error { color: #a33226; }

.reset-tools { margin-top: 16px; text-align: center; }
.reset-tools button { min-height: 44px; padding: 8px 14px; border: 1px solid #cfb8b1; border-radius: 10px; background: #fff; color: #913f30; font-size: .76rem; }
