:root {
  --color-background: #fff;
  --color-surface: #f8fafc;

  --color-text: #222;
  --color-text-secondary: #666;
  --color-text-muted: #999;

  --color-border: #d4d4d8;
  --color-border-light: #e5e7eb;

  --color-control-background: #f8fafc;
  --color-control-hover: #e5e7eb;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;

  --color-icon: #555;
  --color-icon-hover: #f0f0f0;

  --color-input-border: #ccc;
  --color-input-background: #fff;

  --color-button-text: #fff;

  --color-select-file-border-hover: #b3b3b3;
  --color-drop-active: #2563eb55;

  --color-utility-background: #3c6666;
  --color-utility-text: #fff;

  color: var(--color-text);
  background: var(--color-background);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-background: #121212;
    --color-surface: #1e1e1e;

    --color-text: #eee;
    --color-text-secondary: #bbb;
    --color-text-muted: #888;

    --color-border: #444;
    --color-border-light: #333;

    --color-control-background: #242424;
    --color-control-hover: #333;

    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;

    --color-icon: #ccc;
    --color-icon-hover: #333;

    --color-input-border: #555;
    --color-input-background: #242424;

    --color-button-text: #eee;

    --color-select-file-border-hover: #666;
    --color-drop-active: #60a5fa55;

    --color-utility-background: #2f4f4f;
    --color-utility-text: #eee;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.header {
  padding: 1rem;
  text-align: center;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.header .language-selector {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.utility-header {
  padding: 0.4rem 1rem;
  background: var(--color-utility-background);
  color: var(--color-utility-text);
  font-size: 0.8rem;
}

.utility-nav {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.utility-language,
.utility-links {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.utility-header a {
  color: inherit;
  text-decoration: none;
}

.utility-header a:hover {
  text-decoration: underline;
}

.utility-separator {
  opacity: 0.6;
}

.lang-ja {
  display: none;
}

html[lang="ja"] .lang-en {
  display: none;
}

html[lang="ja"] .lang-ja {
  display: inline;
}

.container {
  width: 100%;
  padding: 1rem;
}

/* Preview */

.preview-title,
#result-section h2 {
  margin-top: 1.5rem;
  font-size: 1.2rem;
}

.preview-title {
  margin-bottom: 0.5rem;
  line-height: 1.4;
  min-height: 1.4em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-filename-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  line-height: 1.5;
  min-height: 1.5em;
  color: var(--color-text-secondary);
}

#placeholder-upload-filename {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-muted);
}

#select-file-button {
  min-height: 36px;
  padding: 0 0.9rem;
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-control-background);
  color: var(--color-text);
}

#select-file-button:hover {
  background: var(--color-control-hover);
  border-color: var(--color-select-file-border-hover);
  color: var(--color-text-secondary);
}

.map-shell {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.map-shell.drop-active {
  box-shadow: inset 0 0 0 3px var(--color-drop-active);
}

.map-shell.completed {
  /* pointer-events: none; */
  opacity: 0.82;
}

.map {
  width: 100%;
  height: 320px;
}

.upload-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  font-size: 1.2rem;
}

button {
  min-height: 44px;
  padding: 0 1.5rem;
  border: 0;
  border-radius: 8px;
  background: var(--color-primary);
  color: var(--color-button-text);
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: var(--color-primary-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Result */

.result-item {
  margin-top: 1rem;
}

.result-item label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.copy-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-field input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--color-input-border);
  border-radius: 6px;
  background: var(--color-control-background);
  color: var(--color-text);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.copy-button-wrapper {
  position: relative;
  display: inline-block;
}

.copy-field > button,
.copy-button-wrapper button {
  min-height: 44px;
  width: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-field button svg {
  width: 20px;
  height: 20px;
}

.copy-field button {
  background: transparent;
  color: var(--color-icon);
}

.copy-field button:hover {
  background: var(--color-icon-hover);
}

.copy-message {
  position: absolute;
  right: 0;
  bottom: 100%;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.result-item-separator {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
}

.notice {
  margin: 1.5rem 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.secret-input-wrapper {
  position: relative;
  flex: 1;
}

.secret-input-wrapper input {
  background: var(--color-control-background);
  color: var(--color-text);
  width: 100%;
  padding-right: 3rem;
}

.secret-input-wrapper button {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.secret-input-wrapper button svg {
  width: 24px;
  height: 24px;
}

/* Before uploading */

#before-uploading-section {
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

#before-uploading-section h3 {
  font-size: 1rem;
}

/* Status */

#status-section {
  margin-top: 0.5rem;
}

#status-message {
  margin: 0;
  min-height: 1.3rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* Desktop */

@media (min-width: 768px) {
  .container {
    max-width: 640px;
    margin: 0 auto;
  }

  .map {
    height: 420px;
  }
}