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

:root {
  --bg:      #f5f4ee;
  --surface: #eceade;
  --line:    #e2dfd0;
  --accent:  #6fb942;
  --ink:     #0f1a0a;
  --ink-2:   #2d3a25;
  --ink-3:   #5f6c54;
  --ink-4:   #9aa48d;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.logo-icon {
  display: inline-grid;
  place-items: center;
  width: 1.24em;
  height: 1.24em;
  border-radius: 0.3em;
  background: #000;
  overflow: hidden;
}

.logo-icon-svg {
  width: 100%;
  height: 100%;
}

.logo-icon-svg text {
  fill: var(--accent);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 42px;
  font-weight: 700;
}

.logo-text {
  letter-spacing: 0.12em;
}
.app-hint {
  position: fixed;
  bottom: 16px;
  right: 20px;
  font-size: 0.7rem;
  color: var(--ink-4);
  letter-spacing: 0.01em;
}

.logo-a {
  font-size: 1.1em;
  opacity: 0.55;
  letter-spacing: 0;
}

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

.format-switch {
  position: relative;
  cursor: pointer;
  user-select: none;
}
.format-switch input {
  display: none;
}
.format-switch-track {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 0;
  height: 36px;
}
.format-switch-opt {
  position: relative;
  z-index: 1;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  border-radius: 999px;
  transition: color 0.2s;
  min-width: 32px;
  text-align: center;
}
.format-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--bg);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(15,26,10,0.10);
  transition: transform 0.2s cubic-bezier(.4,0,.2,1);
}
.format-switch:has(input:checked) .format-switch-thumb {
  transform: translateX(100%);
}
.format-switch:has(input:not(:checked)) .format-switch-opt:first-of-type { color: var(--ink); }
.format-switch:has(input:checked) .format-switch-opt:last-of-type { color: var(--ink); }

/* Shared icon button base */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.icon-btn:hover {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--ink-4);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* Now button: capsule, same height as toggle */

/* Shared tooltip — used by JS-positioned dot tooltips and tutorial hints */
.tau-tooltip {
  position: fixed;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
.tau-tooltip.visible { opacity: 1; }

/* Hover label tooltip */
.icon-btn::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.icon-btn:hover::after { opacity: 1; }

/* Add clock: accent-filled variant */
#add-clock-btn {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
#add-clock-btn:hover {
  background: var(--ink-2);
  border-color: transparent;
  color: #fff;
}

main {
  flex: 1 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  padding: 48px 32px;
  justify-content: center;
}

.seo-footer {
  width: 100%;
  border-top: 1px solid var(--line);
  padding: 12px 16px 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  font-size: 0.74rem;
  color: var(--ink-4);
}

.seo-footer-label {
  font-weight: 600;
  color: var(--ink-3);
}

.seo-footer a {
  color: var(--ink-4);
  text-decoration: none;
}

.seo-footer a:hover {
  color: var(--ink-2);
  text-decoration: underline;
}

.empty-state {
  width: 100%;
  text-align: center;
  color: var(--ink-4);
  margin-top: 80px;
  font-size: 1.05rem;
}

/* Clock card */
.clock-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  transition: opacity 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.clock-card.drag-ghost { opacity: 0.35; }
.clock-card.dragging   { cursor: grabbing; }

/* Card controls capsule */
.card-controls {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}
.clock-card:hover .card-controls { opacity: 1; }

.card-controls [data-label] {
  position: relative;
}
.card-controls [data-label]::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.card-controls [data-label]:first-child::after {
  left: 0;
  transform: none;
}
.card-controls [data-label]:hover::after { opacity: 1; }


.drag-handle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 4px;
  padding: 2px 0;
  margin-right: -2px;
  cursor: grab;
}
.drag-handle span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-4);
  display: block;
}

.clock-label-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.clock-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.clock-label--local {
  color: var(--accent);
}

.clock-offset-label {
  font-size: 0.75rem;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-align: center;
}

.clock-offset-label .dst-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  vertical-align: middle;
  line-height: 1.4;
}

.clock-time-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0;
  line-height: 1;
}
.clock-time-inner {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  border-bottom: 1px dashed var(--ink-4);
  transition: border-color 0.15s;
  padding-bottom: 1px;
}
.clock-time-inner:hover { border-bottom-style: solid; border-bottom-color: var(--ink-3); }
.clock-time-row:has(.clock-time-text:focus) .clock-time-inner {
  border-bottom: 2px solid var(--accent);
}

.ampm-toggle {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: none;
  background: transparent;
  padding: 0;
  text-align: center;
  cursor: pointer;
  user-select: none;
  color: var(--ink-4);
  transition: color 0.15s;
  line-height: 1;
}
.ampm-toggle[data-meridiem="pm"] { color: var(--ink); }
.ampm-toggle:hover { color: var(--ink); }

.clock-time-text.hint-blink {
  animation: hint-caret-blink 1s step-start infinite;
}
@keyframes hint-caret-blink {
  0%, 100% { box-shadow: inset -2px 0 0 var(--ink); }
  50% { box-shadow: none; }
}
.clock-time-text {
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  width: 5ch;
  transition: color 0.15s;
  cursor: text;
  padding: 0;
  line-height: 1;
}

.remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px;
  margin-left: -5px;
  color: var(--ink-4);
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s;
  flex-shrink: 0;
}
.remove-btn:hover { color: var(--ink); }

/* Tutorial hint labels — extend shared tooltip */
.tutorial-hint { transition: opacity 0.3s ease; }
#hint-type { transition: opacity 0.3s ease, top 0.4s ease; }

/* Fake hand hint on page load */
#fake-hand {
  position: fixed;
  width: 12px;
  height: 19px;
  overflow: visible;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transform: translate(0, 0);
  transition: left 0.25s ease-out,
              top  0.25s ease-out,
              opacity 0.3s ease;
}
#fake-hand.visible { opacity: 1; }
#fake-hand.fading  { opacity: 0; }
@keyframes hand-grab {
  0%   { transform: scale(1);    }
  50%  { transform: scale(0.88); }
  100% { transform: scale(1);    }
}
#fake-hand.grabbing { animation: hand-grab 0.35s ease-in-out forwards; }

@keyframes drag-hint {
  0%   { transform: scale(1);   opacity: 0.7; }
  45%  { transform: scale(3.5); opacity: 0; }
  100% { transform: scale(3.5); opacity: 0; }
}
.dot-min-ripple {
  animation: drag-hint 2.8s ease-out 10;
  pointer-events: none;
}

/* SVG Clock */
.clock-svg {
  cursor: grab;
  user-select: none;
  filter: drop-shadow(0 2px 12px rgba(15,26,10,0.10));
}
.clock-svg:active { cursor: grabbing; }

/* Modal */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,26,10,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: overlay-in 0.15s ease;
}
#modal-overlay.hidden { display: none; }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#modal {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: min(520px, 85vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(15,26,10,0.18), 0 2px 8px rgba(15,26,10,0.10);
  animation: modal-in 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

#modal-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#modal-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.tz-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.tz-search-icon {
  position: absolute;
  left: 11px;
  color: var(--ink-4);
  pointer-events: none;
  display: flex;
}

#tz-search {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 9px 12px 9px 34px;
  font-size: 0.95rem;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
#tz-search::placeholder { color: var(--ink-4); }
#tz-search:focus { border-color: var(--accent); }

#tz-result-count {
  font-size: 0.75rem;
  color: var(--ink-4);
  text-align: right;
  margin-top: -6px;
  min-height: 1em;
}

#tz-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
#tz-list::-webkit-scrollbar { width: 5px; }
#tz-list::-webkit-scrollbar-track { background: transparent; }
#tz-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.tz-group-header {
  padding: 8px 8px 3px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  user-select: none;
}

#tz-list li {
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-2);
  transition: background 0.1s, color 0.1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#tz-list li:hover,
#tz-list li.tz-active {
  background: var(--surface);
  color: var(--ink);
}

.tz-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.tz-city {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tz-region {
  font-size: 0.75rem;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tz-offset {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
#tz-list li:hover .tz-offset,
#tz-list li.tz-active .tz-offset {
  background: var(--line);
  color: var(--ink-3);
}

#tz-empty {
  display: none;
  padding: 32px 16px;
  text-align: center;
  color: var(--ink-4);
  font-size: 0.9rem;
}

#modal-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-hint {
  font-size: 0.72rem;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-hint kbd {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.68rem;
  font-family: inherit;
  color: var(--ink-3);
}

#modal-cancel {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}
#modal-cancel:hover { border-color: var(--ink-3); color: var(--ink); }

@media (max-width: 600px) {
  header {
    padding: 16px;
  }

  .logo {
    font-size: 1.25rem;
    gap: 8px;
  }

  .seo-footer {
    justify-content: flex-start;
    font-size: 0.7rem;
  }

  #modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  #modal {
    width: 100%;
    max-width: 100%;
    /* Fixed height — doesn't shrink/grow with results or keyboard */
    height: 60vh;
    min-height: 60vh;
    max-height: 60vh;
    border-radius: 18px 18px 0 0;
    animation: modal-in-mobile 0.22s cubic-bezier(0.32,0.72,0,1);
  }

  @keyframes modal-in-mobile {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  #modal-header {
    padding: 14px 16px 12px;
    flex-shrink: 0;
  }

  /* Drag handle pill at top of sheet */
  #modal-header::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 0 auto 6px;
  }

  #tz-search {
    font-size: 1rem;
  }

  #tz-list {
    /* List takes remaining space and scrolls within it */
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #tz-list li {
    padding: 11px 10px;
  }

  /* Hide keyboard hints on touch */
  .modal-hint { display: none; }

  #modal-footer {
    justify-content: center;
    padding: 10px 16px 20px;
    flex-shrink: 0;
  }

  #modal-cancel {
    width: 100%;
    padding: 11px;
    font-size: 0.95rem;
    text-align: center;
  }
}
