:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #18201d;
  --muted: #65706b;
  --line: #dce2de;
  --teal: #147d78;
  --teal-deep: #0d5351;
  --coral: #cf624d;
  --blue: #426f9d;
  --gold: #b98325;
  --shadow: 0 18px 44px rgba(28, 45, 38, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1320px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.workspace-header,
.session-actions,
.summary-strip,
.map-heading,
.country-heading,
.filter-row,
.region-filters,
.quick-filters {
  display: flex;
  align-items: center;
}

.topbar,
.workspace-header,
.map-heading,
.country-heading,
.filter-row {
  justify-content: space-between;
}

.topbar,
.workspace-header {
  gap: 18px;
}

.topbar {
  min-height: 48px;
}

.session-actions,
.summary-strip,
.region-filters {
  flex-wrap: wrap;
}

.session-actions {
  justify-content: flex-end;
  gap: 7px;
}

.back-link,
.toolbar-button,
.status-pill,
.sync-status,
.user-pill,
.map-reset-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  text-decoration: none;
}

.back-link,
.toolbar-button,
.map-reset-button {
  font-weight: 700;
}

.status-pill,
.sync-status,
.user-pill {
  color: var(--muted);
  font-size: 0.84rem;
}

.status-pill {
  color: var(--teal-deep);
  font-weight: 700;
}

.sync-status.is-error {
  color: #913c30;
  border-color: #e8beb7;
  background: #fff6f4;
}

.toolbar-button {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.secondary-button {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
}

.workspace-header {
  align-items: flex-end;
  padding: 40px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font: 700 0.76rem "Space Grotesk", sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 4rem;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.summary-strip {
  gap: 8px;
  justify-content: flex-end;
}

.summary-strip div {
  min-width: 108px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--summary-color, var(--teal));
  border-radius: 7px;
  background: var(--surface);
}

.summary-strip div:nth-child(2) {
  --summary-color: var(--blue);
}

.summary-strip div:nth-child(3) {
  --summary-color: var(--gold);
}

.summary-strip span,
.summary-strip strong {
  display: block;
}

.summary-strip span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-strip strong {
  font: 700 1.5rem "Space Grotesk", sans-serif;
}

.view-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px;
  background: #e8ece9;
}

.view-tab {
  min-height: 40px;
  border: 0;
  border-radius: 5px;
  padding: 8px 16px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.view-tab:hover,
.view-tab:focus-visible {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
}

.view-tab.is-active {
  color: #fff;
  background: var(--teal-deep);
  box-shadow: 0 4px 10px rgba(13, 83, 81, 0.16);
}

.view-panel[hidden] {
  display: none;
}

.map-section,
.country-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-section {
  padding: 18px;
}

.map-heading,
.country-heading {
  gap: 16px;
  margin-bottom: 16px;
}

.map-reset-button {
  color: var(--blue);
}

.world-map {
  width: 100%;
  height: min(58vh, 620px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #dfe9e6;
  isolation: isolate;
}

.leaflet-container {
  font-family: "Noto Sans KR", sans-serif;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
  background: var(--surface);
}

.visit-marker-wrap {
  border: 0;
  background: transparent;
}

.visit-marker-pin {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  position: absolute;
  top: 2px;
  left: 2px;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 8px;
  background: var(--coral);
  box-shadow: 0 5px 12px rgba(51, 35, 31, 0.28);
  transform: rotate(-45deg);
}

.visit-marker-pin span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.map-popup strong,
.map-popup span {
  display: block;
}

.map-popup strong {
  margin-bottom: 3px;
}

.map-popup span {
  color: var(--muted);
  font-size: 0.82rem;
}

.map-popup-detail-button {
  width: 100%;
  min-height: 32px;
  margin-top: 9px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  background: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
}

.map-fallback {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
}

.country-section {
  margin-top: 20px;
  padding: 22px;
}

.timeline-view,
.stats-view {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading,
.timeline-heading,
.stats-block-heading,
.timeline-year-heading,
.timeline-entry-meta,
.timeline-entry-actions {
  display: flex;
  align-items: center;
}

.section-heading,
.timeline-heading,
.stats-block-heading,
.timeline-year-heading {
  justify-content: space-between;
}

.section-heading,
.timeline-heading {
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.timeline-year-filter {
  min-width: 150px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.timeline-year-filter select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 32px 7px 10px;
  color: var(--ink);
  background: var(--surface-soft);
  font: inherit;
}

.timeline-list {
  display: grid;
  gap: 30px;
}

.timeline-year-group {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 24px;
}

.timeline-year-heading {
  align-self: start;
  align-items: flex-start;
  flex-direction: column;
  gap: 5px;
  position: sticky;
  top: 14px;
}

.timeline-year-heading h3 {
  margin: 0;
  color: var(--teal-deep);
  font: 700 1.65rem "Space Grotesk", "Noto Sans KR", sans-serif;
}

.timeline-year-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

.timeline-entries {
  display: grid;
  gap: 12px;
  position: relative;
  padding-left: 28px;
}

.timeline-entries::before {
  content: "";
  width: 2px;
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 7px;
  background: #c8d8d2;
}

.timeline-entry {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 15px 16px;
  background: var(--surface-soft);
}

.timeline-entry::before {
  content: "";
  width: 12px;
  height: 12px;
  position: absolute;
  top: 22px;
  left: -27px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 1px rgba(207, 98, 77, 0.25);
}

.timeline-marker {
  padding-top: 2px;
  color: var(--teal-deep);
  font: 700 0.84rem "Space Grotesk", sans-serif;
}

.timeline-entry-body {
  min-width: 0;
}

.timeline-entry-meta {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-entry-meta span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.timeline-entry h4 {
  margin: 8px 0 4px;
  font-size: 1.15rem;
  word-break: break-word;
}

.timeline-entry p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-entry-actions {
  justify-content: flex-end;
  gap: 7px;
  margin-top: 12px;
}

.timeline-entry-actions .record-action-button {
  min-height: 32px;
}

.timeline-detail-link {
  border-color: rgba(20, 125, 120, 0.3);
  color: var(--teal-deep);
  background: rgba(20, 125, 120, 0.08);
}

.timeline-edit-button {
  color: var(--blue);
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats-overview > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  border-right: 1px solid var(--line);
  padding: 17px 20px;
}

.stats-overview > div:first-child {
  padding-left: 0;
}

.stats-overview > div:last-child {
  border-right: 0;
  padding-right: 0;
}

.stats-overview span,
.stats-overview small,
.stats-block-heading span {
  color: var(--muted);
}

.stats-overview span {
  font-size: 0.82rem;
  font-weight: 700;
}

.stats-overview strong {
  color: var(--teal-deep);
  font: 700 1.8rem "Space Grotesk", "Noto Sans KR", sans-serif;
}

.stats-overview small {
  overflow: hidden;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.stats-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 18px;
  background: var(--surface-soft);
}

.stats-block-wide {
  grid-column: 1 / -1;
}

.stats-block-heading {
  gap: 12px;
  margin-bottom: 18px;
}

.stats-block-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.stats-block-heading span {
  font-size: 0.74rem;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(68px, 96px) minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
}

.bar-row > span,
.bar-row strong {
  font-size: 0.78rem;
}

.bar-row strong {
  color: var(--teal-deep);
  text-align: right;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 5px;
  background: #e0e7e3;
}

.bar-fill {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--teal);
}

.chart-empty {
  margin: 0;
  padding: 22px 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.month-chart {
  height: 180px;
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  gap: 8px;
  align-items: end;
  overflow-x: auto;
  padding-bottom: 4px;
}

.month-column {
  min-width: 34px;
  height: 100%;
  display: grid;
  grid-template-rows: 22px minmax(80px, 1fr) 22px;
  gap: 5px;
  align-items: end;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

.month-column strong {
  color: var(--ink);
  font-size: 0.74rem;
}

.month-track {
  width: 70%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-self: center;
  overflow: hidden;
  border-radius: 4px 4px 2px 2px;
  background: #e0e7e3;
}

.month-track span {
  width: 100%;
  display: block;
  border-radius: inherit;
  background: var(--coral);
}

.repeat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.repeat-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
}

.repeat-item:hover,
.repeat-item:focus-visible {
  border-color: rgba(20, 125, 120, 0.5);
  background: #eff8f5;
}

.repeat-rank {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--teal-deep);
  background: #e4f2ef;
  font: 700 0.75rem "Space Grotesk", sans-serif;
}

.repeat-item strong {
  overflow: hidden;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repeat-item > span:last-child {
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.stats-empty-state {
  margin-top: 20px;
}

.country-heading {
  align-items: flex-end;
}

.search-field {
  width: min(320px, 100%);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--surface-soft);
  outline: none;
}

.search-field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 125, 120, 0.14);
}

.filter-row {
  gap: 14px;
  margin-bottom: 18px;
}

.region-filters {
  gap: 6px;
}

.quick-filters {
  gap: 14px;
  flex: 0 0 auto;
}

.region-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 11px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.region-button.is-active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.list-toggle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.list-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.country-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.country-item {
  min-width: 0;
  min-height: 88px;
  display: block;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px;
  background: var(--surface-soft);
}

.country-item.is-favorite {
  border-color: rgba(185, 131, 37, 0.54);
}

.country-item:hover {
  border-color: #b4c5bd;
  background: #fff;
}

.country-item.is-visited {
  border-color: rgba(20, 125, 120, 0.44);
  background: #eff8f5;
}

.country-overview {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: 22px 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 0;
  padding: 4px 112px 4px 6px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.country-overview:focus-visible {
  border-radius: 5px;
  outline: 3px solid rgba(66, 111, 157, 0.24);
  outline-offset: 1px;
}

.country-actions {
  display: flex;
  gap: 5px;
  position: absolute;
  top: 6px;
  right: 7px;
  z-index: 2;
}

.custom-check {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid #aab6b0;
  border-radius: 5px;
  background: #fff;
}

.country-item.is-visited .custom-check {
  border-color: var(--teal);
  background: var(--teal);
}

.country-item.is-visited .custom-check::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translateY(-1px) rotate(-45deg);
}

.country-flag {
  font-size: 1.3rem;
  line-height: 1;
}

.country-copy {
  min-width: 0;
}

.country-copy strong,
.country-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-copy strong {
  font-size: 0.9rem;
}

.country-copy small {
  margin-top: 2px;
  color: var(--muted);
  font: 500 0.72rem "Space Grotesk", sans-serif;
}

.country-copy .visit-summary {
  margin-top: 7px;
  color: var(--teal-deep);
  font-family: "Noto Sans KR", sans-serif;
  font-weight: 700;
}

.country-item:not(.is-visited) .visit-summary {
  color: var(--muted);
  font-weight: 500;
}

.locate-button,
.favorite-button,
.add-visit-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--blue);
  background: #eaf0f6;
  font-size: 1.1rem;
  font-weight: 700;
}

.add-visit-button {
  color: var(--teal-deep);
  background: #e4f2ef;
  font-size: 1.25rem;
}

.add-visit-button:hover,
.add-visit-button:focus-visible {
  color: #fff;
  background: var(--teal);
}

.favorite-button {
  color: #8a671f;
  background: #f7efd9;
  font-size: 1.25rem;
}

.favorite-button.is-active,
.favorite-button:hover,
.favorite-button:focus-visible {
  color: #fff;
  background: var(--gold);
}

.locate-button:hover,
.locate-button:focus-visible {
  color: #fff;
  background: var(--blue);
}

.empty-state {
  margin: 0;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  text-align: center;
}

.data-credit {
  padding: 16px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.data-credit a {
  color: var(--blue);
}

.visit-count-badge {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  position: absolute;
  top: -4px;
  right: -7px;
  z-index: 2;
  border: 2px solid #fff;
  border-radius: 10px;
  padding: 0 4px;
  color: #fff;
  background: var(--teal-deep);
  font: 700 0.66rem "Space Grotesk", sans-serif;
  box-shadow: 0 3px 8px rgba(30, 48, 41, 0.2);
}

.visit-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(860px, calc(100vh - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(21, 34, 29, 0.28);
}

.visit-dialog::backdrop {
  background: rgba(24, 32, 29, 0.48);
}

.dialog-header,
.form-heading,
.history-heading,
.visit-record-row,
.record-actions {
  display: flex;
  align-items: center;
}

.dialog-header,
.form-heading,
.history-heading,
.visit-record-row {
  justify-content: space-between;
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 3;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 20px 22px;
  background: rgba(255, 255, 255, 0.97);
}

.dialog-country-summary {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.dialog-close-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 1.5rem;
  line-height: 1;
}

.dialog-close-button:hover,
.dialog-close-button:focus-visible {
  color: #fff;
  background: var(--ink);
}

.visit-form {
  border-bottom: 1px solid var(--line);
  padding: 20px 22px 22px;
  background: var(--surface-soft);
}

.form-heading {
  margin-bottom: 13px;
}

.form-heading h3,
.history-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.text-button {
  border: 0;
  padding: 4px;
  color: var(--blue);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 700;
}

.visit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 10px;
}

.visit-fields label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.visit-fields input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.visit-fields input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 125, 120, 0.12);
}

.form-error {
  margin: 10px 0 0;
  color: #913c30;
  font-size: 0.82rem;
  font-weight: 700;
}

.primary-dialog-button {
  min-height: 42px;
  margin-top: 12px;
  border: 0;
  border-radius: 6px;
  padding: 9px 16px;
  color: #fff;
  background: var(--teal);
  font-weight: 700;
}

.visit-history {
  padding: 20px 22px 24px;
}

.history-heading {
  gap: 12px;
  margin-bottom: 8px;
}

.history-heading span {
  color: var(--teal-deep);
  font-size: 0.84rem;
  font-weight: 700;
}

.visit-record-row {
  gap: 14px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.record-copy {
  min-width: 0;
}

.record-copy strong,
.record-copy span {
  display: block;
}

.record-copy strong {
  font-size: 0.9rem;
}

.record-copy span {
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.82rem;
}

.record-actions {
  gap: 5px;
  flex: 0 0 auto;
}

.record-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--blue);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.record-action-button.detail-link {
  border-color: rgba(20, 125, 120, 0.28);
  color: var(--teal-deep);
  background: rgba(20, 125, 120, 0.08);
}

.record-action-button.delete-button {
  color: #913c30;
}

.empty-visit-records {
  margin: 0;
  padding: 24px 0 8px;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
}

@media (max-width: 1000px) {
  .country-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .workspace-header,
  .country-heading,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .session-actions,
  .summary-strip {
    justify-content: flex-start;
  }

  .search-field {
    width: 100%;
  }

  .quick-filters {
    justify-content: flex-start;
  }

  .country-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-year-group {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 14px;
  }

  .timeline-entry {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .stats-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-overview > div:nth-child(2) {
    border-right: 0;
  }

  .stats-overview > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .stats-overview > div:first-child,
  .stats-overview > div:last-child {
    padding: 17px 20px;
  }

  .repeat-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 12px;
  }

  .session-actions,
  .session-actions > * {
    width: 100%;
  }

  .status-pill,
  .sync-status,
  .user-pill {
    text-align: center;
  }

  h1 {
    font-size: 2.5rem;
  }

  .summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .summary-strip div {
    min-width: 0;
    padding: 11px 10px;
  }

  .view-tabs {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .view-tab {
    min-width: 0;
    padding-inline: 6px;
    font-size: 0.84rem;
  }

  .world-map {
    height: 390px;
    min-height: 390px;
  }

  .map-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-reset-button {
    width: 100%;
  }

  .country-section,
  .map-section {
    padding: 14px;
  }

  .timeline-view,
  .stats-view {
    min-height: 420px;
    padding: 16px;
  }

  .section-heading,
  .timeline-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .timeline-year-filter {
    width: 100%;
  }

  .timeline-year-group {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .timeline-year-heading {
    align-items: baseline;
    flex-direction: row;
    position: static;
  }

  .timeline-entries {
    padding-left: 18px;
  }

  .timeline-entries::before {
    left: 5px;
  }

  .timeline-entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding: 13px;
  }

  .timeline-entry::before {
    left: -18px;
  }

  .timeline-marker {
    padding: 0;
  }

  .timeline-entry-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .timeline-entry-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-entry-actions .record-action-button {
    min-width: 0;
    white-space: normal;
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-block-wide {
    grid-column: auto;
  }

  .stats-overview > div {
    padding: 14px 10px;
  }

  .stats-overview > div:first-child,
  .stats-overview > div:last-child {
    padding: 14px 10px;
  }

  .stats-overview strong {
    font-size: 1.45rem;
  }

  .stats-overview small {
    white-space: normal;
  }

  .repeat-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .region-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .region-button {
    padding-inline: 5px;
  }

  .country-grid {
    grid-template-columns: 1fr;
  }

  .visit-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }

  .dialog-header,
  .visit-form,
  .visit-history {
    padding-inline: 16px;
  }

  .visit-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .place-field {
    grid-column: auto;
  }

  .primary-dialog-button {
    width: 100%;
  }

  .visit-record-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .record-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .record-action-button {
    min-width: 0;
    white-space: normal;
  }
}
