:root {
  --primary: #4a3b32;
  --secondary: #f6eedf;
  --accent: #c19a49;
  --accent-bright: #e8c97f;
  --dark-blue: #1f3a5f;
  --steel: #9aa1a8;
  --gold: #c19a49;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--secondary);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(193,154,73,0.14), transparent 60%),
    repeating-linear-gradient(45deg, #3d3029 0 2px, #453630 2px 4px),
    #2b211c;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  padding-left: 10px;
  padding-right: 10px;
}

/* Leather wallet stitching */
body::before {
  content: "";
  position: fixed;
  inset: 8px;
  border: 2px dashed rgba(193,154,73,0.35);
  border-radius: 14px;
  pointer-events: none;
  z-index: 0;
}

header.app-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 22px 0 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #e0bd6b, #a37e35);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.5);
  font-size: 18px;
}
.brand-name {
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 4px;
  color: var(--accent-bright);
  text-shadow: 0 2px 3px rgba(0,0,0,0.6), 0 0 12px rgba(193,154,73,0.4);
  text-transform: uppercase;
}
.brand-tag {
  font-size: 11px;
  letter-spacing: 1px;
  color: #cbb9a2;
  margin-top: 4px;
  font-style: italic;
}

.screen {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
}

.tab-title {
  color: var(--accent-bright);
  text-align: center;
  letter-spacing: 2px;
  font-weight: normal;
  margin: 18px 0;
  text-transform: uppercase;
}

/* ---- Counters ---- */
.counters {
  display: flex;
  gap: 12px;
  margin: 6px 0 16px;
}
.counter.plate {
  flex: 1;
  text-align: center;
  padding: 14px 6px;
  background: linear-gradient(180deg, #cdb065, var(--accent) 55%, #8f6f2f);
  border-radius: 8px;
  box-shadow: 0 5px 12px rgba(0,0,0,0.45), inset 0 1px 2px rgba(255,255,255,0.4);
  color: #fff;
  position: relative;
}
.counter.plate::before,
.counter.plate::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f0e2b8, #7c6126);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.5);
}
.counter.plate::before { top: 6px; left: 6px; }
.counter.plate::after { top: 6px; right: 6px; }
.counter-num {
  display: block;
  font-size: 30px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  text-shadow: 0 2px 3px rgba(0,0,0,0.4);
}
.counter-label {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  margin-top: 4px;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ---- Search ---- */
.search-wrap { margin-bottom: 12px; }
.search-wrap input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #5c4a3d;
  background: rgba(0,0,0,0.3);
  color: var(--secondary);
  font-size: 14px;
  font-family: inherit;
}
.search-wrap input::placeholder { color: #9a8873; }
.search-wrap input:focus { outline: none; border-color: var(--accent); }

/* ---- Buttons ---- */
.btn {
  font-family: inherit;
  border: none;
  border-radius: 8px;
  padding: 13px 18px;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 0.5px;
}
.btn-new {
  width: 100%;
  background: linear-gradient(180deg, #e0bd6b, var(--accent) 55%, #9a7a33);
  color: #fff;
  font-weight: bold;
  box-shadow: 0 5px 12px rgba(0,0,0,0.45), inset 0 1px 2px rgba(255,255,255,0.5);
  margin-bottom: 16px;
}
.btn-primary {
  background: linear-gradient(180deg, #e0bd6b, var(--accent));
  color: #fff;
  font-weight: bold;
}
.btn-danger { background: #7a2f2f; color: #fff; font-weight: bold; }
.btn-ghost { background: #5c4a3d; color: var(--secondary); }
.btn-close { background: transparent; color: var(--accent-bright); border: 1px solid var(--accent); }

/* ---- Tagboard & cards ---- */
.tagboard { display: flex; flex-direction: column; gap: 14px; }
.empty-state {
  text-align: center;
  color: #b9a68e;
  padding: 30px 10px;
  font-style: italic;
}
.empty-state .empty-icon { font-size: 34px; }

.trip-card {
  position: relative;
  background: #f4ead8;
  color: #3a2c22;
  border-radius: 8px;
  padding: 16px 14px 18px 30px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.5);
  cursor: pointer;
  border: 1px solid #d9c9a8;
}
/* eyelet (die-cut hole illusion) */
.trip-card::before {
  content: "";
  position: absolute;
  top: 14px; left: 10px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6b5a48, #2b211c 70%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8), 0 1px 1px rgba(255,255,255,0.4);
}
/* leather strap stub */
.trip-card::after {
  content: "";
  position: absolute;
  top: -12px; left: 12px;
  width: 22px; height: 18px;
  border-radius: 3px;
  background: linear-gradient(180deg, #7a6a56, #4e4134);
  border: 1px solid #33291f;
  box-shadow: 0 2px 3px rgba(0,0,0,0.5);
}

.card-pin {
  position: absolute;
  top: 10px; right: 10px;
  color: var(--accent);
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.card-name {
  font-size: 20px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
  letter-spacing: 0.5px;
}
.card-dest {
  font-size: 15px;
  color: var(--dark-blue);
  font-weight: bold;
  margin: 6px 0 12px;
  letter-spacing: 0.5px;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.card-date {
  font-size: 12px;
  color: #8a7a63;
  font-style: italic;
}
/* flip-digit board */
.flip-board {
  background: #12100d;
  border-radius: 4px;
  padding: 6px 10px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  position: relative;
  text-align: center;
  min-width: 86px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.8);
}
.flip-board::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(255,255,255,0.12);
  transform: translateY(-50%);
}
.flip-board small {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---- Parchment panels ---- */
.parchment {
  background:
    linear-gradient(rgba(0,0,0,0.03), rgba(0,0,0,0.03)),
    var(--secondary);
  color: #3a2c22;
  border-radius: 10px;
  border: 3px solid #b9a87f;
  outline: 1px solid #6b5a44;
  padding: 16px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.4);
}
.parchment.stitched {
  border: 2px dashed #8f7a5a;
  outline: 3px solid #6b5a44;
}
.panel-message {
  text-align: center;
  color: #7d6a51;
  font-style: italic;
  padding: 20px 8px;
}

/* ---- Documents ---- */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px dashed #c9b892;
}
.doc-item:last-child { border-bottom: none; }
.doc-icon { font-size: 22px; }
.doc-name { flex: 1; font-weight: bold; color: #3a2c22; }
.doc-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

/* ---- Editor overlay ---- */
#editor-overlay, #modal-overlay, #form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.editor-sheet, .form-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--secondary);
  color: #3a2c22;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 90vh;
  overflow-y: auto;
}
.editor-head, .form-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.editor-title, .form-title {
  font-weight: bold;
  color: var(--primary);
  letter-spacing: 1px;
}
#editor-area {
  width: 100%;
  min-height: 40vh;
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  border-radius: 8px;
  border: 2px solid #c9b892;
  background: #fffdf6;
  color: #3a2c22;
  resize: none;
}
#editor-area:focus, .field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---- Modal ---- */
.modal {
  width: 90%;
  max-width: 340px;
  background: var(--secondary);
  color: #3a2c22;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-actions .btn { flex: 1; }

/* ---- Form ---- */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: #7d6a51;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field-label em { color: #a03030; font-style: normal; }
.field input, .field textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #c9b892;
  background: #fffdf6;
  color: #3a2c22;
  font-family: inherit;
  font-size: 15px;
}
.form-errors { color: #a03030; font-size: 13px; margin-bottom: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { flex: 1; }

/* ---- Bottom tab bar ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: #2b211c;
  border-top: 2px solid #5c4a3d;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 40;
  box-shadow: 0 -4px 14px rgba(0,0,0,0.5);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #a89a85;
}
.pull {
  display: block;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #cfd3d8, #8f959c);
  box-shadow: 0 3px 5px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.5);
  position: relative;
}
.pull-nub {
  position: absolute;
  top: 7px; left: 7px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f2f4f6, #a9afb6);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.7), inset 0 -1px 2px rgba(0,0,0,0.4);
}
.tab-btn.active { color: var(--accent-bright); }
.tab-btn.active .pull {
  background: linear-gradient(145deg, #f0cf8d, #c19a49 50%, #8f6f2f);
  box-shadow: 0 3px 8px rgba(193,154,73,0.6), inset 0 1px 2px rgba(255,255,255,0.6);
}
.tab-btn.active .pull-nub {
  background: radial-gradient(circle at 35% 30%, #fff7e0, #e0bd6b);
}
.tab-label { font-size: 10px; letter-spacing: 0.5px; }