:root {
  --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --panel: rgba(255, 255, 255, 0.95);
  --text: #2d3748;
  --text-light: #718096;
  --muted: #a0aec0;
  --line: rgba(203, 213, 224, 0.3);
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --blue: #4299e1;
  --blue-dark: #452d87;
  --green: #48bb78;
  --green-dark: #452d87;
  --yellow: #ecc94b;
  --yellow-dark: #d69e2e;
  --red: #f56565;
  --red-dark: #e53e3e;
  --r: 24px;
  --r2: 20px;
  --safeTop: env(safe-area-inset-top, 0px);
  --safeBottom: env(safe-area-inset-bottom, 0px);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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


.menuWrap{
  position: relative;
  display:flex;
  align-items:center;
  justify-content:flex-end;
}

/* Visible, on-brand menu button */
.menuBtn{
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 14px;
  border-radius: 18px;
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color:#fff;
  font-weight: 800;
  cursor:pointer;
  box-shadow: 0 12px 18px -8px rgba(66, 153, 225, .45);
  transition: var(--transition);
}
.menuBtn:active{ transform: scale(.98); }
.menuIcon{ font-size: 18px; line-height: 1; }
.menuText{ font-size: 14px; letter-spacing: .2px; }

/* Menu panel matches light UI */
.menuPanel{
  position:absolute;
  top: 52px;
  right: 0;
  min-width: 210px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display:none;
  z-index: 50;
}

/* Menu actions look like your UI buttons */
.menuItem{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  text-align:center;
  padding: 12px 14px;
  border-radius: 16px;
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color:#fff;
  cursor:pointer;
  font-weight: 800;
  transition: var(--transition);
}
.menuItem + .menuItem{ margin-top: 10px; }
.menuItem:hover{ filter: brightness(1.02); }
.menuItem:active{ transform: scale(.99); }

/* Delete button variant */
.menuItem.danger{
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color:#000000;
}
/* Divider and PIN row inside menu */
.menuDivider{
  height:1px;
  background: var(--line);
  margin: 12px 4px;
  border-radius: 1px;
}
.menuRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 8px 6px 12px 6px;
}
.menuRowLabel{
  font-weight: 800;
  color: var(--text);
  font-size: 14px;
}

/* iOS-style switch */
.switch{
  position: relative;
  display: inline-block;
  width: 46px;
  height: 28px;
}
.switch input{
  opacity: 0;
  width: 0;
  height: 0;
}
.slider{
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.12);
  transition: .2s;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.slider:before{
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  top: 2px;
  background: #fff;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 6px 12px rgba(0,0,0,0.18);
}
.switch input:checked + .slider{
  background: linear-gradient(135deg, var(--blue), var(--green));
  border-color: transparent;
}
.switch input:checked + .slider:before{
  transform: translateX(18px);
}

/* PIN Gate overlay */
.pinGate{
  position: fixed;
  inset: 0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  z-index: 9999;
  padding: 18px;
}
.pinGate.show{ display:flex; }
.pinCard{
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.pinTitle{
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 6px;
}
.pinHint{
  font-size: 13px;
  opacity: .8;
  margin-bottom: 12px;
}
.pinInput{
  width: 100%;
  padding: 14px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.75);
  color: var(--text);
  font-size: 18px;
  letter-spacing: 3px;
  text-align: center;
  outline: none;
}
.pinInput:focus{
  border-color: rgba(66,153,225,0.55);
  box-shadow: 0 0 0 4px rgba(66,153,225,0.18);
}
.pinActions{
  display:flex;
  justify-content:center;
  margin-top: 12px;
}
.pinError{
  margin-top: 10px;
  color: var(--red-dark);
  font-weight: 800;
  text-align:center;
  min-height: 20px;
}



body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(12px + var(--safeTop)) 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

/* Top-right 3-dot menu */

.iconBtn:active{ transform: translateY(1px); }


.menuPanel.show{ display:block; }

/* NOTE: Menu items are styled above to match the main UI buttons.
   Do not override hover colors here (it caused white-on-white / red-on-red). */


.brand-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 10px 15px -3px rgba(66, 153, 225, 0.3);
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
}

.logo::after {
  content: '🎙️';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

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

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue-dark), var(--green-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  border: 1px solid var(--line);
  background: white;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  letter-spacing: 0.3px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
}

.btn.neutral {
  background: rgba(255,255,255,0.85);
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.btn.neutral:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.10);
}

.btn.blue {
  background: linear-gradient(135deg, var(--blue), #63b3ed);
  border-color: transparent;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn.green {
  background: linear-gradient(135deg, var(--green), #9ae6b4);
  border-color: transparent;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn.yellow {
  background: linear-gradient(135deg, var(--yellow), #faf089);
  border-color: transparent;
  color: #744210;
}

.btn.red {
  background: linear-gradient(135deg, var(--red), #fc8181);
  border-color: transparent;
  color: white;
}

.search {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: 30px;
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
  position: relative;
}

.search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 10px 15px -3px rgba(66, 153, 225, 0.3);
}

.search input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 1rem;
  background: transparent;
}

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

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--muted);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition);
  opacity: 0;
  pointer-events: none;
}

.search-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.search-clear:hover {
  background: var(--red);
  transform: translateY(-50%) scale(1.1);
}

.tabs {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  padding: 10px 20px;
  border-radius: 40px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.tab.active {
  background: linear-gradient(135deg, var(--blue), var(--green));
  border-color: transparent;
  color: white;
  box-shadow: 0 10px 15px -3px rgba(66, 153, 225, 0.3);
}

.content {
  padding: 20px 16px calc(100px + var(--safeBottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.ph {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  background: linear-gradient(to right, rgba(66, 153, 225, 0.05), rgba(72, 187, 120, 0.05));
}

.ph h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.ph p {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-light);
  line-height: 1.4;
}

.body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hint {
  font-size: 0.875rem;
  color: var(--text-light);
  line-height: 1.5;
  padding: 16px;
  background: rgba(66, 153, 225, 0.05);
  border-radius: var(--r2);
  border-left: 4px solid var(--blue);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--r2);
  padding: 16px;
  background: white;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transform: translateX(-100%);
  transition: var(--transition);
}

.card:hover::before {
  transform: translateX(0);
}

.card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow);
  border-color: transparent;
}

.icon {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(66, 153, 225, 0.1);
  border: 1px solid rgba(66, 153, 225, 0.2);
  flex: 0 0 auto;
  font-size: 1.5rem;
  transition: var(--transition);
}

.card:hover .icon {
  transform: scale(1.1) rotate(5deg);
  background: var(--blue);
  border-color: transparent;
  color: white;
}

.icon.green {
  background: rgba(72, 187, 120, 0.1);
  border-color: rgba(72, 187, 120, 0.2);
}

.card:hover .icon.green {
  background: var(--green);
}

.icon.yellow {
  background: rgba(236, 201, 75, 0.1);
  border-color: rgba(236, 201, 75, 0.2);
}

.card:hover .icon.yellow {
  background: var(--yellow);
}

.meta {
  flex: 1;
  min-width: 0;
}

.t {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text);
}

.s {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--text-light);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.badges {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 40px;
  background: #f7fafc;
  border: 1px solid var(--line);
  color: var(--text-light);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge.blue {
  background: rgba(66, 153, 225, 0.1);
  border-color: rgba(66, 153, 225, 0.3);
  color: var(--blue-dark);
}

.badge.green {
  background: rgba(72, 187, 120, 0.1);
  border-color: rgba(72, 187, 120, 0.3);
  color: var(--green-dark);
}

.badge.yellow {
  background: rgba(236, 201, 75, 0.1);
  border-color: rgba(236, 201, 75, 0.3);
  color: #975a16;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.mini {
  border: 1px solid var(--line);
  background: white;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mini:hover {
  background: var(--blue);
  border-color: transparent;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(66, 153, 225, 0.3);
}

.mini:active {
  transform: translateY(0);
}

audio {
  width: 100%;
  border-radius: 12px;
  margin: 8px 0;
}

.bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safeBottom));
  z-index: 25;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

.bottom .wrap {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
}

.big {
  flex: 1;
  padding: 16px 20px;
  border-radius: 30px;
  border: none;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 20px 25px -5px rgba(66, 153, 225, 0.4);
  transition: var(--transition);
  letter-spacing: 0.5px;
}

.big:hover {
  transform: translateY(-4px);
  box-shadow: 0 30px 30px -5px rgba(66, 153, 225, 0.5);
}

.big:active {
  transform: translateY(0);
}

.big.secondary {
  flex: 0 0 auto;
  background: white;
  color: var(--text);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  width: 60px;
  font-size: 1.5rem;
  padding: 16px 0;
}

.backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 40;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: min(560px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 32px 32px 0 0;
  box-shadow: 0 -20px 25px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: calc(100dvh - 24px - env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheetHead {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: linear-gradient(to right, rgba(66, 153, 225, 0.05), rgba(72, 187, 120, 0.05));
  position: sticky;
  top: 0;
  background: white;
  z-index: 5;
}

.sheetHead h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue-dark), var(--green-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sheetBody {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Create-sheet compact mode (prevents scrolling on small phone screens) */
.sheetBody.createMode {
  padding: 12px;
  gap: 12px;
}

.sheetBody.createMode .hint {
  padding: 10px 12px;
  font-size: 0.85rem;
}

.sheetBody.createMode .card {
  padding: 12px;
  gap: 12px;
}

.sheetBody.createMode .icon {
  width: 40px;
  height: 40px;
  border-radius: 16px;
  font-size: 1.25rem;
}

.sheetBody.createMode .t {
  font-size: 0.98rem;
}

.sheetBody.createMode .s {
  margin-top: 6px;
  -webkit-line-clamp: 1;
}

.sheetBody.createMode .badge {
  padding: 4px 10px;
  font-size: 0.72rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}

input, textarea, select {
  width: 100%;
  margin-top: 4px;
  border-radius: 20px;
  border: 2px solid var(--line);
  padding: 14px 18px;
  font-size: 1rem;
  outline: none;
  background: white;
  color: var(--text);
  transition: var(--transition);
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.sheetFoot {
  padding: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  background: linear-gradient(to right, rgba(66, 153, 225, 0.02), rgba(72, 187, 120, 0.02));
  position: sticky;
  bottom: 0;
  background: white;
  flex: 0 0 auto;
}

.err {
  display: none;
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 20px;
  border: 1px solid var(--red);
  background: rgba(245, 101, 101, 0.1);
  color: var(--red-dark);
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.pill {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 40px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, white, #f7fafc);
  color: var(--text-light);
  white-space: nowrap;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.livebox {
  border: 2px solid var(--line);
  border-radius: var(--r2);
  padding: 16px;
  background: linear-gradient(135deg, rgba(66, 153, 225, 0.05), rgba(72, 187, 120, 0.05));
  transition: var(--transition);
}

.livebox:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

.liveTitle {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.liveText {
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 80px;
  padding: 16px;
  background: white;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Voice recording specific styles */
.recording-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--red);
  color: white;
  border-radius: 40px;
  font-size: 0.875rem;
  font-weight: 600;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.recording-dot {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Responsive improvements */
@media (min-width: 640px) {
  .app {
    margin: 20px auto;
    border-radius: 32px;
    min-height: calc(100vh - 40px);
  }
  
  .bottom {
    max-width: 560px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 32px 32px 0 0;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --blue: #0000ff;
    --green: #008000;
    --text: #000000;
    --line: #000000;
  }
  
  .card {
    border-width: 2px;
  }
}

/* Touch target optimization */
button, 
[role="button"],
.tab,
.mini,
.big,
.search-clear {
  min-height: 48px;
  min-width: 48px;
}

/* Focus indicators */
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* Loading state */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Success animation */
@keyframes success {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.success {
  animation: success 0.3s ease;
}

/* Waveform animation for recording */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}

.waveform span {
  width: 4px;
  height: 20px;
  background: var(--blue);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.waveform span:nth-child(2) { animation-delay: 0.1s; }
.waveform span:nth-child(3) { animation-delay: 0.2s; }
.waveform span:nth-child(4) { animation-delay: 0.3s; }
.waveform span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 20px; }
  50% { height: 40px; }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--line);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--blue);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--blue-dark);
}

/* ===== Top-right Menu Button (more visible) ===== */

.menuBtn:active{transform:scale(.98);}
.menuBtn .menuText{font-size:14px; letter-spacing:.3px;}




/* Lock interactions when PIN gate is visible */
body.locked .app, body.locked .bottom{ pointer-events:none; filter: blur(2px); }

/* === PDF Scan UI additions (v3) === */
.btn.rose{
  background: linear-gradient(145deg, #ffb6c1, #ff7f9f);
  color:#1b1b1b;
  font-weight:800;
}
.roseCard{
  border: 1px solid rgba(255, 127, 159, .45);
  box-shadow: 0 10px 30px rgba(255, 127, 159, .10);
}
.scanActionsTop{ display:flex; gap:10px; flex-wrap:wrap; }
.scanActionsTop .btn{ flex:1; min-width:140px; }
.radioPill{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 12px;
  border-radius:14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
}
.radioPill input{ margin-right:6px; }
.row2{ display:flex; gap:10px; flex-wrap:wrap; }
.rowNoWrap{ flex-wrap:nowrap; }
.radioPill{ white-space:nowrap; }
.row2 > *{ flex:1; min-width:140px; }

/* Attachment box */
.attachBox{
  margin-top:10px;
  padding:10px;
  border-radius:14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}
.attachRow{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

/* Danger button: keep menu theme background, make text/icon red */
.menuBtn.dangerBtn,
.menuBtn.dangerBtn .menuText,
.menuBtn.dangerBtn .menuIcon{
  color: #ff4d4d !important;
}



/* Compatibility helpers for newer button classnames */
.btn.primary{ background: var(--blue); color:#fff; }
.btn.menuLike{ background: rgba(0,0,0,.05); color: var(--text); border-color: var(--line); }
@media (prefers-color-scheme: dark){ .btn.menuLike{ background: rgba(255,255,255,.08); color:#fff; border-color: rgba(255,255,255,.18);} }
.btn.ghost{ background: transparent; border:1px solid rgba(255,255,255,.18); }
.btn.mini{ padding:8px 10px; font-size:13px; border-radius:12px; }


/* Small menu-style buttons (used in modals) */
.menuBtn.sm{
  padding:8px 12px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 10px 16px -10px rgba(191, 41, 205, 0.45);
}
.sheetFootRow{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
  width:100%;
}


/* ===== Cropper (PDF Scan) ===== */
.cropWrap{display:flex; flex-direction:column; gap:10px;}
.cropCanvasWrap{position:relative; width:100%; border-radius:14px; overflow:hidden; background:rgba(0,0,0,.25); border:1px solid rgba(255,255,255,.08);}
#cropCanvas{width:100%; height:auto; display:block; touch-action:none;}
.cropHint{font-size:12px; opacity:.8;}



/* =========================
   Note Detail Modal: maximize note text area
   (Additive, does not affect other modals)
   ========================= */
#backdrop .sheet.noteSheet{
  display:flex;
  flex-direction:column;
  max-height: 92vh;
  overflow: hidden; /* prevents nested scroll; body area becomes main read area */
}

#backdrop .sheet.noteSheet .sheetHead{
  position: sticky;
  top: 0;
  z-index: 10;
}

#backdrop .sheet.noteSheet .sheetBody.noteDetailMode{
  flex: 1 1 auto;
  overflow: hidden;
  padding: 14px 16px;
  gap: 12px;
}

#backdrop .sheet.noteSheet .sheetFoot{
  flex: 0 0 auto;
}

/* Layout inside note modal */
.noteModal{
  display:flex;
  flex-direction:column;
  height: 100%;
  gap: 10px;
}

.noteTopRow{
  display:flex;
  align-items:center;
  gap: 10px;
}

.noteTitleInput{
  flex: 1 1 auto;
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 18px;
  font-weight: 700;
}

.noteRemRow{
  margin-top: 0;
}

/* Note text gets ~80%+ of the available area */
.noteBodyBig{
  flex: 1 1 auto;
  min-height: 46vh;
  resize: none;
  line-height: 1.55;
  font-size: 1.05rem;
  padding: 14px 16px;
}

/* Reminder icon button uses menu theme */
.iconBtn{
  width: 44px;
  height: 44px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
  font-size: 18px;
  box-shadow: 0 12px 18px -10px rgba(66, 153, 225, 0.45);
  transition: var(--transition);
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.iconBtn:hover{ transform: translateY(-2px); }
.iconBtn:active{ transform: translateY(0); }

/* Make attachment box compact in note modal */
.noteDetailMode .attachBox{
  padding: 12px;
}

.iconCloseBtn{
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iconCloseBtn img{
  width: 42px;
  height: 42px;
  object-fit: contain;
  pointer-events: none;
}

/* Image icon inside iconBtn / menuLike buttons */
.uiBtnIcon{
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}


/* v68a note background colors */
.noteBgPickerWrap{
  margin-top:12px;
}
.noteBgPicker{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(92px,1fr));
  gap:10px;
  margin-top:10px;
}
.noteBgSwatch{
  border:2px solid rgba(255,255,255,.12);
  border-radius:16px;
  min-height:54px;
  padding:10px 8px;
  cursor:pointer;
  display:flex;
  align-items:flex-end;
  justify-content:flex-start;
  text-align:left;
  color:#1b1b1b;
  font-weight:700;
}
.noteBgSwatch span{
  background:rgba(255,255,255,.76);
  padding:4px 8px;
  border-radius:999px;
  font-size:.75rem;
  line-height:1;
}
.noteBgSwatch.active{
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(66,153,225,.16);
}
.noteColorRow{
  margin-top:4px;
}
.noteColorCard{
  transition:transform .18s ease, box-shadow .18s ease;
}
.noteBodyBig{
  border:1px solid rgba(255,255,255,.14);
}


/* ===== Advanced PDF crop / adjustments ===== */
.cropWrapAdvanced{ gap:12px; }
.cropLegend{ display:flex; flex-wrap:wrap; gap:8px; }
.cropCanvasWrap{ min-height: 220px; }
.pdfAdjustBox{
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}
#pdfBrightness, #pdfContrast, #thr{ width:100%; }
/* =========================================
   Mobile Title Size Fix (Save Vertical Space)
   Only affects Android / small screens
   ========================================= */

@media (max-width: 768px) {

  /* Main note titles */
  .np-title,
  .noteTitle,
  .modalTitle,
  .np-modal-title,
  .editorTitle,
  .note-editor-title {
      font-size: 16px !important;
      line-height: 1.2;
      font-weight: 600;
  }

  /* Section titles like Text Note / Speech → Text */
  .np-section-title,
  .noteTypeTitle {
      font-size: 15px !important;
      font-weight: 600;
  }

}

/* ===== Modal phone-size unification ===== */
@media (max-width: 640px) {
  .backdrop {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }

  .sheet {
    width: 100%;
    max-width: 100%;
    min-height: calc(100dvh - 20px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 20px - env(safe-area-inset-bottom, 0px));
    border-radius: 26px 26px 0 0;
  }

  .sheetHead {
    padding: 14px 14px 12px;
    flex: 0 0 auto;
  }

  .sheetBody,
  .sheetBody.createMode {
    padding: 14px;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
  }

  .sheetFoot {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  }
}
