:root {
  color: #17233f;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.app-shell {
  width: min(100% - 32px, 720px);
  margin-inline: auto;
  padding-block: 48px 64px;
}

h1,
h2 {
  margin-top: 0;
}

h1 {
  margin-bottom: 32px;
  font-size: 2rem;
  letter-spacing: 0.04em;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.125rem;
}

form {
  display: grid;
  gap: 16px;
}

textarea {
  width: 100%;
  min-height: 12rem;
  padding: 16px;
  resize: vertical;
  border: 1px solid #aeb7c8;
  border-radius: 6px;
  color: inherit;
  background: #ffffff;
  font: inherit;
  line-height: 1.7;
}

textarea:focus-visible,
button:focus-visible,
.ai-button:focus-visible,
.file-input-label:focus-within {
  outline: 3px solid #92a9d6;
  outline-offset: 2px;
}

.file-input-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #aeb7c8;
  border-radius: 6px;
  color: #314568;
  background: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

#itinerary-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.supporting-text {
  min-width: 0;
  margin: 0;
  color: #5c6679;
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.file-note {
  flex-basis: 100%;
}

.maps-note {
  margin-top: 16px;
}

button {
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  background: #17233f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  color: #687184;
  background: #d9dee8;
  cursor: not-allowed;
  opacity: 1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions > :first-child {
  flex: 1 1 180px;
}

.app-feedback {
  margin: -4px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  color: #8a2929;
  background: #fff1f1;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.secondary-button {
  min-width: 88px;
  border: 1px solid #aeb7c8;
  color: #314568;
  background: #ffffff;
  font-weight: 600;
}

.result {
  min-width: 0;
  margin-top: 40px;
}

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

.result-header h2 {
  margin-bottom: 0;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.result-action-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid #aeb7c8;
  color: #314568;
  background: #ffffff;
  font-weight: 600;
}

.copy-button {
  min-height: 44px;
  padding: 9px 18px;
  flex: 0 0 auto;
}

.copy-feedback {
  min-height: 1.5em;
  margin: 0 0 8px;
  color: #314568;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.copy-feedback.is-error {
  color: #9a2f2f;
}

.ai-handoff {
  margin-top: 28px;
}

.file-handoff-guide {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 6px;
  color: #243758;
  background: #eef2f8;
  font-size: 0.875rem;
  line-height: 1.6;
}

.file-handoff-guide p {
  margin: 0;
}

.file-handoff-guide .attachment-name {
  margin-top: 6px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.recommend-reason {
  margin: 0 0 10px;
  color: #5c6679;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.ai-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid #17233f;
  border-radius: 6px;
  color: #17233f;
  background: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.ai-button.is-recommended {
  color: #ffffff;
  background: #17233f;
}

.handoff-feedback {
  margin: 10px 0 0;
  color: #314568;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.handoff-feedback.is-error {
  color: #9a2f2f;
}

.rebuild-control {
  margin-top: 24px;
  text-align: center;
}

.rebuild-toggle {
  min-height: 44px;
  padding: 8px 4px;
  color: #5c6679;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rebuild-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.rebuild-options[hidden] {
  display: none;
}

.rebuild-options button {
  min-height: 44px;
  padding: 8px;
  border: 1px solid #aeb7c8;
  color: #314568;
  background: #ffffff;
  font-size: 0.8125rem;
  font-weight: 600;
}

.rebuild-options button.is-current {
  border-color: #17233f;
  background: #eef2f8;
}

pre {
  width: 100%;
  min-width: 0;
  max-height: 65vh;
  margin: 0;
  overflow: auto;
  padding: 20px;
  border: 1px solid #d9dee8;
  border-radius: 6px;
  background: #f7f8fa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 380px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding-block: 32px 48px;
  }

  h1 {
    margin-bottom: 24px;
    font-size: 1.75rem;
  }

  .form-actions > :first-child {
    flex-basis: 100%;
  }

  .secondary-button {
    flex: 1 1 100%;
  }

  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions button {
    flex: 1 1 0;
    min-width: 0;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 640px) {
  .app-shell {
    padding-block: 72px 96px;
  }

  button {
    justify-self: start;
    min-width: 180px;
  }

  .copy-button,
  .secondary-button,
  .result-action-button {
    min-width: auto;
  }

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

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