:root {
  --bg-primary: #000000;
  --bg-secondary: #0b0d10;
  --bg-tertiary: #151920;
  --bg-card: #202733;
  --text-primary: #ffffff;
  --text-secondary: #c4c8cf;
  --text-muted: #858b95;
  --accent-primary: #00d4ff;
  --accent-secondary: #49e58f;
  --danger: #ff4c6a;
  --warning: #ffb84a;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.45);
  --radius-sm: 8px;
  --radius-md: 8px;
}

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

html,
body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg-primary);
}

body {
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

#app {
  width: 600px;
  height: 600px;
  padding: 8px;
  position: relative;
}

.screen {
  width: 584px;
  height: 584px;
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: 8px;
}

.screen.hidden { display: none; }

.header {
  min-height: 64px;
  padding: 12px 14px;
  background: rgba(11, 13, 16, 0.82);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header h1 {
  flex: 1;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
}

.header-meta {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn {
  width: 56px;
  height: 48px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 24px;
}

.content {
  flex: 1;
  min-height: 0;
  padding: 12px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.content-tight {
  padding-bottom: 8px;
}

.capture-panel,
.reader-card {
  background: rgba(32, 39, 51, 0.72);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.mode-pill,
.note-count {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(21, 25, 32, 0.78);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.2;
}

.mode-pill.recording {
  color: #061016;
  background: var(--accent-primary);
}

.text-input {
  width: 100%;
  color: var(--text-primary);
  background: rgba(21, 25, 32, 0.78);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 14px;
}

.note-input {
  min-height: 210px;
  resize: none;
  font-size: 18px;
  line-height: 1.35;
}

.text-input::placeholder {
  color: var(--text-muted);
}

.photo-preview {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
  align-items: stretch;
  min-height: 104px;
}

.photo-preview img,
.detail-photo {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.remove-photo {
  min-height: 88px;
  color: var(--text-primary);
  background: rgba(21, 25, 32, 0.78);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
}

.nav-bar {
  min-height: 98px;
  padding-top: 10px;
  background: rgba(11, 13, 16, 0.82);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.nav-item {
  min-height: 88px;
  padding: 10px 8px;
  background: rgba(21, 25, 32, 0.82);
  color: var(--text-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
}

#library .nav-bar,
#detail .nav-bar {
  grid-template-columns: repeat(2, 1fr);
}

.nav-item.primary {
  background: var(--accent-primary);
  color: #061016;
}

.nav-item.danger {
  background: var(--danger);
  color: #ffffff;
}

.scroll-frame {
  position: relative;
  min-height: 0;
}

.scroll-frame::before,
.scroll-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 44px;
  pointer-events: none;
  z-index: 2;
}

.scroll-frame::before {
  top: 0;
  background: linear-gradient(to bottom, #000000 0%, rgba(0, 0, 0, 0) 100%);
}

.scroll-frame::after {
  bottom: 0;
  background: linear-gradient(to top, #000000 0%, rgba(0, 0, 0, 0) 100%);
}

.list-container {
  max-height: 394px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 12px;
}

.list-item {
  min-height: 88px;
  padding: 12px;
  background: rgba(21, 25, 32, 0.78);
  color: var(--text-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  text-align: left;
}

.list-item-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-meta,
.empty-state {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.35;
}

.list-item-photo {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.photo-token {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--bg-card);
  color: var(--accent-secondary);
  font-weight: 700;
}

.reader-card {
  overflow-y: auto;
  min-height: 0;
}

.detail-text {
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1.38;
  white-space: pre-wrap;
}

.detail-photo {
  margin-top: 4px;
  max-height: 230px;
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  max-width: 536px;
  transform: translateX(-50%) translateY(-90px);
  padding: 12px 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--accent-primary);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.25;
  transition: transform 0.3s ease;
  z-index: 10;
  pointer-events: none;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--accent-secondary); }

.focusable {
  cursor: pointer;
  transition:
    transform 475ms cubic-bezier(0.6, 0, 0.4, 1),
    border-color 300ms cubic-bezier(0.4, 0.04, 0.5, 1),
    box-shadow 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}

.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  transform: scale(0.96);
}

.hidden {
  display: none !important;
}
