:root {
  --washi: #f2efe7;
  --sumi: #2a2927;
  --muted: #8c877d;
  --hairline: rgba(42, 41, 39, 0.12);
  --shu: #b8432f;
}

* { box-sizing: border-box; margin: 0; }

html, body {
  height: 100%;
  background: var(--washi);
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  font: 500 15px/1.2 "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  letter-spacing: 0.04em;
  color: var(--sumi);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#bath {
  flex: 1;
  position: relative;
  min-height: 0;
}

#water {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 28px;
  padding: 4px max(16px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--hairline);
}

.row {
  display: flex;
  align-items: center;
}

.tools, .actions { flex: 0 1 auto; }

button, .sheet-actions a {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s;
}

.actions button, .sheet-actions button, .sheet-actions a { color: var(--sumi); }

.tools button[aria-checked="true"] { color: var(--sumi); }

.tools button[aria-checked="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--shu);
}

button[aria-pressed="false"] { color: var(--muted); }
button:disabled { opacity: 0.35; cursor: default; }

.seal, .sheet-actions .seal {
  flex: 0 0 auto;
  min-height: 34px;
  margin-left: 6px;
  padding: 0 12px;
  border: 1px solid var(--shu);
  border-radius: 2px;
  color: var(--shu);
}

.inks { gap: 4px; }

.inks button {
  flex: 0 0 auto;
  width: 34px;
  min-height: 44px;
  padding: 0;
}

.inks button::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch);
}

.inks button[aria-checked="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--sumi);
}

#dip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.load {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 26px;
  background: linear-gradient(var(--hairline), var(--hairline)) 0 0 / 100% 1.5px no-repeat,
    linear-gradient(var(--hairline), var(--hairline)) 0 3.5px / 100% 1.5px no-repeat;
}

.load i {
  display: block;
  height: 1.5px;
  transform-origin: left;
}

#load-ink { background: var(--sumi); }
#load-clear { background: #8fb0b8; }

/* Phones: three centred rows. */
@media (max-width: 600px) {
  #bar { row-gap: 0; }
  .row { width: 100%; justify-content: space-between; }
  .inks { justify-content: center; gap: 10px; }
  button, .sheet-actions a { font-size: 14px; padding: 0 4px; letter-spacing: 0.02em; }
  .seal { padding: 0 8px; margin-left: 2px; }
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: #e6e2d8;
}

.sheet[hidden] { display: none; }

#print-img {
  max-width: 100%;
  max-height: calc(100% - 80px);
  min-height: 0;
  filter: drop-shadow(0 6px 18px rgba(60, 50, 30, 0.18));
  animation: settle 0.7s ease-out;
}

@keyframes settle {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sheet-actions a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.credits {
  display: grid;
  gap: 6px;
  text-align: center;
}

.credits dt {
  margin-top: 18px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.credits dt:first-child { margin-top: 0; }

.credits dd { font-size: 17px; }

.credits a {
  color: var(--sumi);
  text-decoration-color: var(--shu);
  text-underline-offset: 4px;
  -webkit-user-select: text;
  user-select: text;
}
