:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --ink: #26231f;
  --muted: #6e675f;
  --line: #ded7cd;
  --accent: #247a63;
  --warn: #9a5a25;
  --shadow: 0 8px 30px rgba(54, 47, 40, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #efe8dc;
}

.login-panel {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.login-panel h1 {
  margin: 12px 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.login-subtitle,
.login-notice {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

.login-field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.login-field input:focus {
  border-color: rgba(36, 122, 99, 0.75);
  outline: 3px solid rgba(36, 122, 99, 0.16);
}

.login-error {
  margin: 0;
  color: #b42318;
  font-size: 14px;
  line-height: 1.5;
}

.login-submit {
  height: 42px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.login-notice {
  margin-top: 18px;
  color: var(--warn);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  user-select: none;
  -webkit-user-select: none;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(247, 244, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.toolbar-title {
  min-width: 132px;
  font-size: 18px;
  font-weight: 700;
}

.page-status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.toolbar-spacer {
  flex: 1;
}

.auth-user {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

button,
select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.toolbar a {
  color: var(--accent);
  font-size: 14px;
  text-decoration: none;
}

.toolbar a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  padding: 0 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

select {
  padding: 0 28px 0 10px;
}

.layout {
  padding: 16px;
  min-height: 0;
}

.image-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  background: #ede7dc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.note-wrap {
  position: relative;
  width: min(100%, 1080px);
  aspect-ratio: 1242 / 1660;
  line-height: 0;
  border-radius: 4px;
  box-shadow: var(--shadow);
  background: white;
  overflow: hidden;
}

.tile-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

.note-tile {
  position: absolute;
  display: block;
  object-fit: fill;
  margin: 0;
  padding: 0;
  border: 0;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.note-hotspot {
  position: absolute;
  min-width: 0;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: rgba(36, 122, 99, 0);
  cursor: pointer;
}

.note-hotspot.source-highlight {
  z-index: 1;
}

.note-hotspot.source-ocr {
  z-index: 2;
}

.note-hotspot.has-audio:hover,
.note-hotspot.has-audio:focus-visible,
.note-hotspot.has-audio.is-playing {
  background: rgba(36, 122, 99, 0.18);
  outline: 2px solid rgba(36, 122, 99, 0.75);
}

.note-hotspot.no-audio:hover,
.note-hotspot.no-audio:focus-visible {
  background: rgba(154, 90, 37, 0.16);
  outline: 2px solid rgba(154, 90, 37, 0.72);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  color: white;
  background: rgba(38, 35, 31, 0.92);
  border-radius: 7px;
  box-shadow: var(--shadow);
  z-index: 40;
}

@media (max-width: 900px) {
  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar-title {
    min-width: 0;
  }

  .page-status {
    width: 100%;
    order: 5;
  }

  .auth-user {
    font-size: 12px;
  }
}

@media (max-width: 520px) {
  .login-panel {
    padding: 24px 18px;
  }

  .login-panel h1 {
    font-size: 23px;
  }

  .toolbar {
    gap: 8px;
  }
}
