/* BOTTOM NAV */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.92); border-top: 1px solid var(--paper2);
  display: flex; padding: 8px 0 24px;
  box-shadow: 0 -8px 32px rgba(15,25,35,0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; padding: 4px 0; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; color: var(--ink3); font-weight: 500; }
.nav-item.active .nav-label { color: var(--accent); font-weight: 700; }
.nav-kuma {
  width: 32px; height: 32px; transition: transform 0.15s;
}
.nav-item.active .nav-kuma { transform: scale(1.15); }
.nav-item:active .nav-kuma { transform: scale(0.92); }

/* MODAL OVERLAY */
.modal-overlay {
  position: absolute; inset: 0; background: rgba(10,18,30,0.55);
  z-index: 100; display: flex; flex-direction: column; justify-content: flex-end;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: white; border-radius: 28px 28px 0 0;
  max-height: min(85vh, calc(100dvh - 18px)); overflow-y: auto; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  transform: translateY(40px); transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: var(--paper3); border-radius: 2px; margin: 0 auto 18px; }
.modal-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.modal-title { font-size: 18px; font-weight: 700; flex: 1; color: var(--ink); }
.edit-toggle-btn {
  flex-shrink: 0; background: var(--paper2); border: 1px solid var(--paper3);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 600;
  color: var(--ink2); cursor: pointer; font-family: inherit; margin-left: 10px;
  transition: all 0.15s;
}
.edit-toggle-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.modal-sub { font-size: 13px; color: var(--ink3); margin-bottom: 16px; }
/* Edit form inside modal */
.edit-form-section { background: var(--paper); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.edit-row { margin-bottom: 10px; }
.edit-row:last-child { margin-bottom: 0; }
.edit-label { font-size: 11px; color: var(--ink3); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.edit-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--paper3); border-radius: 10px; font-size: 14px; font-family: inherit; background: white; color: var(--ink); outline: none; transition: border-color 0.2s; }
.edit-input:focus { border-color: var(--accent); }
.edit-textarea { resize: none; height: 70px; line-height: 1.5; }
.save-btn { background: var(--accent); color: white; border: none; border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer; width: 100%; transition: opacity 0.15s; letter-spacing: 0.02em; }
.save-btn:active { opacity: 0.85; }
.modal-section { margin-bottom: 16px; }
.modal-section-title { font-size: 11px; color: var(--ink3); font-weight: 700; letter-spacing: 0.07em; margin-bottom: 8px; text-transform: uppercase; }
.map-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--blue); color: white; border: none;
  padding: 12px 16px; border-radius: 12px; width: 100%; cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit;
  margin-bottom: 10px; transition: opacity 0.15s;
}
.map-btn:active { opacity: 0.85; }

/* PHOTO / RECEIPT */
.photo-area {
  border: 2px dashed var(--paper3); border-radius: 14px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s; background: var(--paper);
}
.photo-area:hover { border-color: var(--accent); }
.photo-icon { font-size: 32px; margin-bottom: 8px; }
.photo-label { font-size: 13px; color: var(--ink3); }
#receipt-input { display: none; }

.receipt-result {
  background: white; border-radius: 14px; padding: 14px;
  border: 1px solid var(--paper2); margin-top: 10px;
}
.receipt-item-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--paper2); }
.receipt-item-row:last-child { border-bottom: none; }
.receipt-total { display: flex; justify-content: space-between; padding-top: 8px; font-size: 15px; font-weight: 700; }

/* TOOLS PAGE */
.tools-page { padding: 0; }
.tools-segmented {
  position: sticky; top: -16px; z-index: 4;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  background: rgba(240,244,248,0.96); backdrop-filter: blur(10px);
  padding: 5px; margin: -2px 0 14px; border-radius: 14px;
  border: 1px solid rgba(200,216,232,0.75);
}
.tools-segment {
  min-height: 38px; border: none; border-radius: 10px; background: transparent;
  color: var(--ink3); font-size: 13px; font-weight: 800; font-family: inherit; cursor: pointer;
}
.tools-segment.active { background: white; color: var(--accent); box-shadow: var(--shadow); }
.tool-group-hidden { display: none; }
.tool-section { margin-bottom: 20px; }
.tool-section-title { font-size: 11px; font-weight: 700; color: var(--ink3); letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 10px; }
.rate-card { background: white; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid rgba(200,216,232,0.5); }
.handwritten-menu-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 10px; padding: 9px 10px; border: 1px solid var(--paper3); border-radius: 10px;
  background: var(--paper2); color: var(--ink2); font: inherit; text-align: left; cursor: pointer;
}
.handwritten-menu-toggle.active { border-color: #d7a13b; background: #fff8e8; color: #7a5200; }
.handwritten-menu-toggle-title { flex: 0 0 auto; font-size: 12px; font-weight: 800; }
.handwritten-menu-toggle-note { font-size: 10px; line-height: 1.35; text-align: right; }
.rate-input-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.rate-input-row > div { flex: 1; min-width: 0; }
.rate-input { 
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--paper2); border-radius: 10px;
  font-size: 18px; font-family: 'Outfit', sans-serif; font-weight: 600; background: var(--paper);
  outline: none; color: var(--ink); box-sizing: border-box;
}
.rate-label { font-size: 12px; color: var(--ink3); font-weight: 600; letter-spacing: 0.03em; }
.rate-result { font-size: 22px; font-weight: 700; color: var(--accent); font-family: 'Outfit', sans-serif; }
.rate-updated { font-size: 11px; color: var(--ink3); margin-top: 4px; }

.phrase-category { margin-bottom: 14px; }
.phrase-cat-title { font-size: 12px; font-weight: 700; color: var(--ink2); margin-bottom: 6px; padding: 0 2px; }
.phrase-item { 
  background: white; border-radius: 12px; padding: 10px 14px; margin-bottom: 6px;
  border: 1px solid rgba(200,216,232,0.5); cursor: pointer; transition: background 0.15s;
}
.phrase-item:active { background: var(--paper2); }
.phrase-jp { font-size: 15px; font-weight: 500; color: var(--ink); }
.phrase-tw { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.phrase-romaji { font-size: 11px; color: var(--green); margin-top: 1px; }

